Laravel 10 Deploy on Shared Hosting cPanel Tutorial

Laravel 10 Deploy on Shared Hosting cPanel Tutorial

If you have shared hosting and also have cpanel access. And then you want to host or deploy your Laravel applications on shared hosting cpanel. So, In this tutorial, you will learn how to host or deploy Laravel 10 project on shared hosting cpanel.

How to deploy Laravel 10 project on Shared Hosting cPanel

Steps to host or deploy Laravel 10 project on cpanel shared hosting:

  • Step 1: Create a Zip of the Laravel App
  • Step 2: Visit Shared Hosting CPanel
  • Step 3: Extract Your Laravel Zip Directory
  • Step 4: Update Index.php File
  • Step 5: Create a Database User and Import Database
  • Step 6: Add Database Details

Step 1: Create a Zip of the Laravel App

First of all, Compress the Laravel project folder on your local machine and create a zip file.

Step 2: Visit Shared Hosting CPanel

In this step, you need to open your shared hosting cPanel to deploy Laravel project into it. And then follow the below steps:

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

Step 3: Extract Your Laravel Zip Directory

Once you have uploaded your Laravel project zip file.

Then you need to extract this file inside the public_html folder on a web server.

Step 4: Update Index.php File

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

After that it opens in the next tab.

It’s time to update the following line of code in 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 5: Create a Database User and Import Database

In this step, create and import the database as follow:

Create a Database and user as follow:

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

Import SQL file as follow:

  • 1: Now, you need to export your local database as an SQL file
  • 2: Go to Cpanel again and click on PHPMyAdmin
  • 3: After that, click on your created database
  • 4: Click on the import option and import SQL file

Step 6: 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

Deploy Laravel 10 on shared hosting cpanel example; In this tutorial, you have learned from scratch on how to deploy Laravel 10 project on shared hosting cpanel.

Recommended Laravel Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of 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 from a starting stage. As well as demo example.

Leave a Reply

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