Sunday, November 17, 2024
Google search engine
HomeLanguagesHow to Deploy Laravel Project on Cpanel

How to Deploy Laravel Project on Cpanel

To deploy laravel project on cpanel; In this tutorial, you will learn how to deploy laravel 5, 6, 7, 8, 9 project on shared hosting (cpanel).

This tutorial will guide you step by step to deploy laravel project on shared hosting or cpanel.

Deploy Laravel Project on Shared Hosting Cpanel

Use the below given steps and to deploy laravel 5, 6, 7, 8, 9 project on shared hosting (cpanel); as shown below:

  • Step 1: Compress the Entire Laravel Project Folder
  • Step 2: Open Shared Hosting CPanel
  • Step 3: Upload Laravel Zip
  • Step 4: Extract Project Folder
  • Step 5: Update Index.php File
  • Step 6: Upload Database
  • Step 7: Add Database Details

Step 1: Compress the Entire Laravel Project Folder

First of all, Compress the laravel 5, 6, 7, 8, 9 project folder on your local machine and create a zip file.

Step 2: Open Shared Hosting CPanel

In this step, you need to open your shared hosting cPanel to deploy laravel project on Cpanel. And then follow the below steps:

  1. Click on ‘File Manager’
  2. Click on public_html

Step 3: Upload Laravel Zip

Next use the following steps to upload laravel project zip.

  1. Then Click on ‘Upload’
  2. Then upload the created zip file into the root directory. In side public_html direcotry.

Step 4: Extract Project Folder

After successfully uploaded the project zip file, Now you need to extract this file inside public_html folder on web server.

Step 5: Update Index.php File

Navigate to the public_html folder and find index.php file. Then open this file by right click on it and select Code Edit from the menu.

After that it open in next tab.

It’s time to update the following line of code into your index.php file as follow:

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
to:
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

Step 6: Upload Database

In this step, create and import database as follow:

Create Database and user as follow:

  • 1: Go to Cpanel and click database wizard
  • 2: Create new database
  • 3: Create new user
  • 4: Associate user with created database

Import sql file as follow:

  • 1: Now, you need to export your locally database as SQL file
  • 2: Go to cpanel again and click on phpmyadmin
  • 3: After that, click on your created database
  • 4: Click on import option and import sql file

Step 7: Add Database Details

Next, go to your uploaded project root directory and open .env file. Then add database details as follow:

 DB_CONNECTION=mysql 
 DB_HOST=127.0.0.1 
 DB_PORT=3306 
 DB_DATABASE=here your database name here
 DB_USERNAME=here database username here
 DB_PASSWORD=here database password here

Note that these details are entered correctly.

Conclusion

In this tutorial, you have learned How to Deploy Laravel Project on Shared Hosting Cpanel.

Recommended Laravel Tutorials

div class=”gen-info-box”>Recommended:-Laravel PHP Artisan Serve Not Working

RELATED ARTICLES

Most Popular

Recent Comments