How to host a Laravel 5 site with cPanel

Warning: This content was posted a while ago and may be incorrect by now. Please search for more recent guidance with your preferred search engine.

To set Laravel up to function in a shared hosting environment, you’ll need to split the installation. Instead of doing a normal installation into just your project folder, you’ll instead install Laravel into the project folder at the same level as the public_html folder.

composer create-project laravel/laravel project --prefer-dist

Once this is done, move all the files from the project/public folder into the public_html folder.

mv project/public/.* public_html

Edit public_html/index.php, changing

require __DIR__.'/../bootstrap/autoload.php'{semicolon}

$app = require_once __DIR__.'/../bootstrap/app.php'{semicolon}


require __DIR__.'/../project/bootstrap/autoload.php'{semicolon}

$app = require_once __DIR__.'/../project/bootstrap/app.php'{semicolon}

Set the permissions on your storage folder

chmod -R o+w project/storage

Create project/app/SharedHostApplication.php with

<?php namespace App{semicolon}

use IlluminateFoundationApplication{semicolon}

class SharedHostApplication extends Application
    public function publicPath()
        return realpath($this->basePath . '/../public_html'){semicolon}

Lastly, edit project/bootstrap/app.php, changing

$app = new IlluminateFoundationApplication(


$app = new AppSharedHostApplication(

That should do it!