Deploying Laravel Application to Shared Hosting

I added this article to Stackoverflow Laravel Documentation, i thought it would be great if it is in my blog too. Deploying Laravel Project to Shared Hosting is easy.


  • PHP >= 5.5.9
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • First of all archive/zip/compress your project file
  • Now Let say you have shared hosting server and you want to deploy your laravel project / app there. In your Hosting cPanel click on Filemanager it will lead you to another page where you can find the directory/folder called public_html .
  • Upload the compressed project file to public_html directory and extract it
  • Now you can move all your project files to public_html ( just select all project files and click on move, it will pops up a box enter public_html there )
  • Now in cPanel you can find MySQL Databases, Create Database, database user and password plus assign user to your created database in there.
  • After creating database, in cPanel Click on PhpMyAdmin and Select the database you have created. Import the .sql file from your local PhpMyAdmin.
  • Once importing is done, Visit public_html directory and edit .env file
  • In .env change the following lines accordingly
Save the .env file and now visit and your project will dance there.
BUT what if i want don't want /public in my website, i.e i want to run my application on my website root ( for that do the following steps.
Copy all the /public directory files to root directory, and edit index.php.
require __DIR__.'/../bootstrap/autoload.php';
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$app = require_once __DIR__.'/bootstrap/app.php';
Once that is done, in server.php change
 if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
if ($uri !== '/' && file_exists(__DIR__.'/'.$uri)) {
    return false;
require_once __DIR__.'/public/index.php';

require_once __DIR__.'/index.php';

1 comment:

  1. BlueHost is one of the best web-hosting company for any hosting services you need.