How To Deploy Laravel Project On Shared Hosting Cpanel 2024

How To Deploy Laravel Project On Shared Hosting Cpanel 2024

To deploy your Laravel project on cPanel shared hosting, For this, you create a zip file of your Laravel project and upload the zip file on cPanel shared hosting, after that, unzip your Laravel project on cpanel and configure it with the database.

A step-by-step guide on how to deploy Laravel 7, 8, 9,10 & 11 projects on shared hosting (cpanel) 2024:

Step 1: Create Zip Entire Laravel Project

First of all, First of all, compress your Laravel 7, 8, 9,10 & 11 project and create a zip file on your local system.

Step 2: Open Shared Hosting CPanel

Now open your cPanel shared hosting, for this you can follow the steps given below:

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

Step 3: Upload Laravel Zip

Now upload the zip file of the Laravel project that you have created on cPanel shared hosting, for this you can follow the steps given below:

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

Step 4: Unzip Laravel Project on cPanel

Now unzip your uploaded laravel project zip file, navigate to cPanel of your shared hosting and open the public_html directory.

Step 5: Edit Index.php File

Now you have to edit the Index.php file and do some configuration in it, Go to public_html folder and find Index.php file. Then open this file by right clicking 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: Create Database and Upload SQL File

Now you have to create a database and user for your Laravel project and after this, you have to import your SQL file into the database, for this, you can also use the following steps:

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: Configure Database with Shared Hosting

Now you need to go to the root directory of the Laravel app and open the .env file, after this, you can configure your database details as follows:

 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

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

2 replies to How To Deploy Laravel Project On Shared Hosting Cpanel 2024

  1. Thank you.. Very helpful for me

  2. Thank you very much, your article is very good and help me a lot 👍

Leave a Reply

Your email address will not be published. Required fields are marked *