Laravel 10 Deploy on Shared Hosting cPanel Example

1. Purchase a hosting plan from a hosting provider that supports cPanel.

2. Log in to your cPanel account.

3. Create a database for your Laravel 10 application.

4. Create a new FTP account for your application.

5. Upload your Laravel 10 application files to the server using an FTP client.

6. Create a new subdomain for your application.

7. Configure the subdomain to point to the public folder of your application.

8. Configure the database connection in the .env file.

9. Install the dependencies of your application using the command line.

10. Generate an application key using the command line.

11. Test your application to make sure it is working properly.

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 Laravel 10 project on shared hosting cpanel.

Laravel 10 Deploy on Shared Hosting cPanel Example

By using the following simple steps, you can host or deploy laravel 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 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 application 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 direcotry.

Step 3: Extract Your Laravel Zip Directory

Once you have uploaded your laravel project zip file.

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

Step 4: Update Index.php File

Now visit to the public_html folder and find index.php file. Then open index.php 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 5: Create 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 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 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

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?