How to deploy laravel project in linux shared hosting

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.

  1. Create a new folder(example laravelapps) in the same location where public_html  (now it should be at /home/youdomain/laravelapps).
  2. 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.
  3. Now upload the contents in public folder to public_html folder. (/home/yourdomain/public_html/).
  4. Edit index.php file and change path of
    require __DIR__.'/../bootstrap/autoload.php'; and
    $app = require_once __DIR__.'/../bootstrap/app.php';
    require __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  if public directory contents are placed in a sub folder, you can redirect using .htaccess file or  using 

We suggest to buy VPS server  for all Laravel installations for better performance.

  • php, laravel, linux
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

Time Zone Settings

Create / Edit  .htaccess file in the public_html folder and Add the following line to set the...

Restrict access to upload folders

To restrict accessing / executing php or other scripts from uploads or other restricted folders,...