Procedure on how to host your Laravel 5.1.* application on any shared hosting:
- Open Filezilla or any of your favorite FTP Client.
- Login and get into the home directory of your hosting account.
- Create directory called
laravel-app or anything that you want inside your shared hosting account home directory. - Copy everything except
public directory from your application's root directory inside the newly created folder. In this case laravel-app. - Now copy the contents of
public directory in your public_html directory. - Once everything is uploaded, open up
index.php file which resides in public_html directory in any of your favorite text editor.
Change the following line:
require __DIR__.'/../bootstrap/autoload.php';
to
require __DIR__.'/../../laravel-app/bootstrap/autoload.php';
And also change the following line:
$app = require_once __DIR__.'/../bootstrap/app.php';
to
$app = require_once __DIR__.'/../../laravel-app/bootstrap/app.php';
Before Uploading:
Please make sure that you have enabled all the plugins that are required by Laravel application. And also you are using PHP >= 5.5.* . If you don't know how to view which plugins are enabled by default.
Follow these steps:
- Login to your cPanel account from the browser.
- Scroll down way to the bottom where they say select PHP Version. Click on it.
- From the dropdown, select PHP 5.5.6 or any of your choice, but it has to be PHP >= 5.5.*
- There is a list of PHP Extensions below the dropdown that can be installed. You can leave it as it is or select the extension(s) that you wish to install. For example, if your application has file uploading feature, then you need to install the
fileinfo extension by check marking that extension and clicking the button Save.
DONE. Your Laravel application is live on a shared hosting account.
You can check it by going to yourdomain.com
Hope this helps you. Happy Coding. Cheers.