How to deploy Laravel APP in cPanel shared hosting

Many articles that I read has wrong way of deploying Laravel application on shared hosted environment inside cPanel.

Most of them stated that uploading the project folders inside the cPanel and copy the public folder to public_html and modify the Laravel framework ( public/index.php).

I believe the following steps is the correct way to deploy and easier way to maintain continuous integration and continuous delivery.

STEP 1: Login to your cPanel

Login to you cpanel with your login credentials and then go to Advance section and inside it you will find terminal.
Note: Make sure you have SSH access from your provider

STEP 2: Install Composer

Configure your shell environment to use composer

Download composer:

Install composer:

STEP 3: Upload your Project

Upload you project to home directory of the cPanel file manager.

STEP 4: Run Following Commands

Lets say your app is in app folder. Go your your app folder.

to install all php dependencies if you have not uploaded vendor folder.

Then change your environmental variables in the .env file

Generate a new application key

Migrate and seed your database as per you need.

Set the correct folder permissions

STEP 5: Make your app accessible for public

Back up your public_html folder and remove it.

Then create a symlink

Create a symlink for your storage

Run storage link

Your app should work now.

Usage Commands

Other Commands

YOU ARE DONE! HAPPY CODING!

Full Stack developer