Laravel is not designed for shared hosting providers. If you can afford a bit more, we suggest to buy VPS server.
How to deploy in linux shared hosting
Generally in shared hosting all the files are present in public_html directory. For example assume public_html folder at /home/yourdomain/public_html. Now follow the simple 4 steps.
- Create a new folder(example laravelapps) in the same location where public_html (now it should be at /home/youdomain/laravelapps).
- Upload all your laravel project files/code base to that except public folder to newly created directory laravelapps. (You can upload these inside public_html folder also). You need to upload the vendor folder also.
- Now upload the contents in public folder to public_html folder. (/home/yourdomain/public_html/).
- Edit index.php file and change path of
require __DIR__.'/../bootstrap/autoload.php';
and$app = require_once __DIR__.'/../bootstrap/app.php';
torequire __DIR__.'/../laravelapps/bootstrap/autoload.php';
and$app = require_once __DIR__.'/../laravelapps/bootstrap/app.php';
iIf you have multiple projects uploaded to /home/yourdomain/laravelapps you can change index file as,require __DIR__.'/../laravelapps/project_name/bootstrap/autoload.php';
and$app = require_once __DIR__.'/../laravelapps/project_name/bootstrap/app.php';
Make sure you upload all the files in public folder including .htaccess file and make sure your routes are correct in routes.php file.
Now, laravel project which is deployed on a linux shared hosting can now be accessed at yourdomain.com. if public directory contents are placed in a sub folder, you can redirect using .htaccess file or using yourdomain.com/subfolder.
We suggest to buy VPS server for all Laravel installations for better performance.