How to host a Laravel app on a cPanel shared hosting

Filippo Toso
6 min readOct 21, 2018

Not every client wants to spend hundreds of dollars to host their Laravel application especially in the initial phases. In this post I describe the steps I take to deploy a Laravel application in a cPanel shared hosting from start to finish.

The only prerequisite is a cPanel hosting package with SSH access.

Create a new app

On your development machine, create a new Laravel named “project” (I always use project to have consistency between applications):

laravel new project --auth

The — auth parameter automatically sets up the authentication routes, controllers and views.

Setup the public _html folder

As cPanel serves websites from a public_html folder, we need to move the public Laravel folder into a folder named public_html in the parent folder:

cd project
mv public ../public_html

Before you had something like this:

/project/public

Then you got

/project/(…)
/public_html

Having moved the content of the public folder into a different directory structure we need to update some files to point to the right folder. Let’s begin editing the public_html/index.php to point to the right framework folder:

<?phpuse Illuminate\Contracts\Http\Kernel…

--

--

Filippo Toso

Filippo is a software developer who helps medium businesses automate and optimize their internal processes through AI-powered interactive bots.