How to host Laravel app on cPanel


In this article, you will learn how to host a Laravel app on a cPanel, in case you have a local server like WAMP or XAMPP, this would work to test it out before uploading it to cPanel.

The article will cover 2 steps:

  1. How to deploy your app to shared hosting.
  2. How to migrate your databases without running migration commands.

Installing LARAVEL on cPanel 

the first step to host Laravel app on cPanel  is to install the framework under your user, however, if you are on a Shared Hosting plan (restricted or no SSH access) you won't be able to use most of its functionalities. How to properly deploy your LARAVEL Project on a Shared Plan will be covered below in the next section.

  1.  Login to your Cpanel.
  2. Under the SOFTWARE section, choose the Softaculous Apps Installer.
  3. Type Laravel in the search bar and on the next window click Install Now.
  4.  On the next page fill in the requested information and choose Quick Install.
    • Choose Protocol: choose SSL or non-SSL protocol (http/https).
    • Choose Domain: the domain to install the software.
    • In Directory: name of the directory to which you wish the application be installed.

  5. Click Install.

  6. If the Laravel application is installed properly, you will see the message below:

Laravel is installed successfully

How to deploy your app to shared hosting

assume you've finished building your app. I also assume you are using Laravel 5.0 – although this article would be relevant for Laravel 5.1

  1. Compress the entire project folder on your local machine. You'll get a zip file –
  2. Open your shared hosting cPanel.
  3. Click on File Manager.
  4. Click on Upload.
  5. Upload the to the root directory – not the public_html.
  6. Extract the 
  7. Open the laravelProject folder and MOVE the CONTENTS of the public folder to your cpanel’s public_html folder. You can as well delete the empty public folder now.
  8. Navigate to the public_html folder and locate the index.php file. Right-click on it and select Code Edit from the menu.
  9. This will open up another tab showing the cPanel code editor.
  10. change the following lines (22 and 36) from, According to your projects folder name.
‘require __DIR__.’/../bootstrap/autoload.php’;

$app = require_once __DIR__.’/../bootstrap/app.php’;’



$app = require_once __DIR__.’/laravelProject/bootstrap/app.php’;’

11. Go to ( should throw database errors (if you have models running on your app). Not to worry. The next phase is migrating your databases to your shared hosting.


Please do not change the contents of your .htaccess file (Unless you know what you are doing

Migrating your tables

One good thing about Laravel Framework is that it enables you to quickly setup defined databases with a single command php artisan migrate. Since we are using shared hostingwe can not do this without the use of SSH. This can be done easily if you have up to 10 tables. Its straightforward so let's start:

Create a database on your web host

  1. Most cPanel comes with PHPMyAdmin and Mysql Database Wizard. 
  2. Use the Mysql Database wizard to create a Database and User then assign the user to the database allowing all privileges.
  3. Note down the username and password you'll need that soon.
  4. Use the cpanel's PHPMyAdmin to create your tables. To do this efficiently, open up PHPMyAdmin on your local machine.
  5. For each table structure create the exact structure on your cPanel’s PHPMyAdmin.

Importing and exporting databases from a local machine

  1. login to PHPMyAdmin from your computer locate the database your project uses, from the toolbar find the export tool.
  2. After exporting move over to your shared hosting and do the same steps on create database section.
  3. If successfully uploaded you'll see the Success Message

Final Steps

  1. On your cpanel File Manager, navigate to laravelProject.
  2. Go to config/database.php
  3. Right-click and select Code Edit
  4. Locate line 55 – Your MySQL configuration Section.
  5. Change the username and password to your MySQL username and password from your cPanel.


Share this:
FacebookTwitterWhatsAppViberCopy LinkTelegramLinkedIn
Updated on November 16, 2020

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support