I have a laravel 5 site on my localhost. I want to launch it on a shared host but the host is neither providing me with the shell nor it has composer installed. Can I still launch my website on this host? If yes then how? If the answer is no then what should I do?
Yes you can upload via file manager if you wish. Follow below steps
Check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
Create a directory in the same level of public_html and put your project inside that folder (except public folder).
Put the content of public (L5) directly on public_html (don't overwrite the .htaccess file)
Inside public_html all files of public directory of Laravel 5 resides now.
Go to index.php and edit the line 22
#From this
require __DIR__.'/../bootstrap/autoload.php';
#To this
require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
and on line 36
#From this
$app = require_once __DIR__.'/../bootstrap/app.php';
#To this
$app = require_once __DIR__.'/../[framework-folder]/bootstrap/app.php';
Then edit the .htaccess file and add some lines
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]
Hope this works. Worked for me.
You can but you need to upload your local directory after a composer install, including vendor and .env using and FTP client. I wouldn't recommend it though, it makes development really hard. Maybe look into a paas like Heroku to get you started for free.
You also need to make sure that the shared hosting supports the following:
PHP >= 5.5.9
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
as take from the docs
Related
This is the first time I am developing a Laravel Vue app. When I use php artisan serve, everything works fine. But when I load it with http://localhost/myProject/public, assets are not loaded. My images are in img directory inside public folder. I was using blade templating to manage this issue when I use Laravel alone. But now I can't use blade since it is a Vue component. How can I run the project without php artisan serve? My Ultimate aim is to deploy the project in godaddy shared server. Please help me.
Debug your application using 'php artisan serve' while you develop from your local machine.
When you publish it into godaddy,
compress the project folder (say 'my_project') and upload the zip file ('my_project.zip') to 'public_html' directory in godaddy.
unzip the folder.
Now the directory structure will be 'public_html/my_project...'
you will have a 'public' directory inside 'my_project'.
Now create a subdomain which points to the 'public' directory.
That's it. Now load the subdomain.
The assets and api's will work perfectly.
just rungit clone [your_project_address] in the www folder and then run 'php artisan migrate', of course, you should have configured well.
#ThasheelApps this is your solution to access api's.
Create a .htaccess file in root folder and paste the following code there:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This issue occurs many times due index.php in url. if you try your api endpoint including index.php, it will work perfectly. to prevent this issue we need to follow above soution htaccess
Follow these steps:
zip your project after npm run dev and php artisan serve without
any error.
Go to your shared hosting location and outside fo public_html
make a folder name say myproject. Inside this folder extract all
your project files.
cut your public folder from project folder on root, go to your
subdomain folder under public_html and paste.
go to index.php inside public folder and
require DIR.'/../vendor/autoload.php'; and
$app = require_once DIR.'/../bootstrap/app.php'; pointing to your project location on root.
That is all. Enjoy, if you have properly created and attached your DB to your project.
I'm trying to setup laravel (5.4.12) in shared hosting. Following this tutorial I had deleted my public_html and created soft-link for public_html to public folder of laravel project. I had successfully setup laravel (5.3.29) following the same tutorial for my previous project. But this time when I try to open base url it downloads index.php file of public directory of laravel folder. Can anyone help me out.
You can do it without deleting public_html folder.
for routing to public forlder just add these lines to .htaccess files
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Normally PHP files are downloaded when the web server isn't configured to serve PHP files. Sounds like you need to talk to your hosting provider.
Finally found the solution. The issue was with PHP version. I had selected PHP version 7.1.0RC4,I changed it to 7.0.12 and the problem is gone.
Laravel 5 setup without artisan serve command
Rename the server.php in the your Laravel root folder to index.php
copy the .htaccess file from /public directory to your Laravel root
folder.
I make a fresh setup of laravel on localhost (/var/www/html/) with command composer create-project laravel/laravel moduleTesting --prefer-dist.
Then I move all the files inside folder to (/var/www/moduleTesting/setup), then move all the files from public folder(/var/www/moduleTesting/setup/public) to moduleTesting folder(/var/www/html/moduleTesting).
I changed bootstrap file path in index.php file placed in moduleexample.dev folder(/var/www/html/moduleTesting/).
require DIR.'/setup/bootstrap/autoload.php';
$app = require_once DIR.'/../../laravel_setup/bootstrap/app.php';
I also set the permission of folder /var/www/moduleTesting/setup/bootstrap/cache and /var/www/moduleTesting/setup/storage
Then I run command composer dump-autoload in terminal at (/var/www/moduleTesting/).
Then I try to run URL in the browser, and I see the welcome page of laravel app.
Then I install module package caffeinated/modules
Begin by installing the package through Composer.
composer require caffeinated/modules
Once this operation is complete, simply add both the service provider and facade classes to project /var/www/html/moduleTesting/setup/config/app.php file:
Service Provider
Caffeinated\Modules\ModulesServiceProvider::class,
Facade
'Module' => Caffeinated\Modules\Facades\Module::class,
After successful installation, I create a new module by command
make:module Admin and follow easy steps steps and it created successfully and run by hitting URL http://localhost/moduleTesting/admin'.
Issue
Now the problem is when I run URL.'http://localhost/moduleTesting/admin'
it runs successfully but when i run 'http://localhost/moduleTesting/admin'(add '/' only at the end of the same url) it does now work and redirect me to url 'http://localhost/admin'
Does anybody know, please help me how to solve this issue, On the same node if upload the setup on the server in a inner folder and run the same url it also redirect me.
This is probably because .htaccess redirects trailing slashes to an URL without a traling slash.
In this section in your .htaccess file, Apache redirects everything with a trailing slash - if not a folder - to its origin. This causes trouble, because the public of the project is located at a directory.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
Replace the second rule with:
RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301]
Note: it is better not using a directory as your public destination because these kinds of problems occur. You should be better of creating a fake local domain, like: module-test.dev or something.
im newbie with laravel. i have problems when uploading my laravel project to my shared hosting.
when i go into my domain.com/laravel/public/ , i cant see anything. they return it with blank page. no error at all. i dont understand.
i try to follow all instructions in internet, but all i got is nothing.
i change index.php inside of public folder.
from this :
require __DIR__.'/../bootstrap/autoload.php';
into :
$app = require_once __DIR__.'/../bootstrap/app.php';
i also modify my .htaccess file into
RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome-project
RewriteRule ^(.*)$ awesome-project/$1 [L]
but still all i got is blank page.
what can i do to solve this issue?
I'm assuming you're running Apache2? Check your site conf file and make sure the document root is pointed to the public folder.
you should be getting a 404 error if path is incorrect. A white page with a new Laravel installation usually means you need to check the permissions of your storage folders.
From the Laravel 5 documentation:
"Directories within the storage and the bootstrap/cache directories should be writable by your web server"
You should restore your Laravel files to original state, then you must set your host to a laravel/public directory. It will work only if you'll do both steps.
If you have trouble with setting up your web server, you can find an instruction for Apache here:
http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost
Also, don't forget to restart your web server after doing all the changes.
I recently created a website with laravel 4. I used XAMP to test my website on localhost and to make it easier I created a virtual host in the vhosts file which points to the public folder of my Laravel app. The website is working perfectly.
Now I rented a webspace at One.com hoster. I opened the webspace with ftp and when I came on the "root" but there weren't any folders so I guess that the root location is the public location? I don't for sure.
The normal structure of a Laravel app is like this:
--> app
--> bootstrap
--> public
--> vendor
--> other files
This doesn't work because I think that One.com doesn't use a public html folder. I tried to make it work but unfortunately. I moved the contents of the public folder to the root of my domain and moved all the other folders in a folder named core. Then I changed some config files index.php and paths.php but still it doesn't work.
The question is what do I need to change to my folder structure to let it work on this One.com webserver and which files I need to adapt (.htaccess, paths.php)? I would like to protect my private folders of course.
Thanks in advance.
Just place .htaccess file in the root folder with data below:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
one.com does use a public_html folder because that's where your files are served from. What you can't get to is your home folder. Xampp is a windows package - have you made sure your filenames follow case conventions? Windows being case insensitive, and Linux being sensitive.