In this video we are going to learn about Project Deployment On Shared Hosting. So let see how can we Deploy this Laravel Project on Shared Hosting.

So first of all go to the project directory and select all file and compress these file into zip So select all and right click then click and choose compress to zip file.

Alright
Now go to http://localhost/phpmyadmin/ and open the database laravel8ecommercedb and now export this database. So click on export link and export the database in .sql.
Now you will get laravel8ecommercedb.sql file.

Now go to the shared hosting cpanel and here first of all lets check the php version, which version is active on this cpanel.
So in software section Click on change version, and here you can current version on php is 7.2. But for Laravel 8 php 7.3 is required. So lets change the php version, from here select php 7.3. Now click on save.

Now go to cpanel dabshord page And now lets create a database.So click on database and here enter the any name of the database like ecommerce.

Now add a user Add enter the user name and password after creating the user assign the privillages to the user. so in privillage section slelect user and database. Now click add and here select all now save. Now go back to cpanel dashboard and this time click on phpmyamdinicon. And from here lets open the database. Now click on sql and lets open the exported datatabase sql file in text editor and copy all the text and paste here. Now click on go


All right all tables are now added in database. Now lets upload the project zip file. So open the filemanager then public_html. Now click on upload. Browser the zip file. And select project zip and click on upload. Now extract the zip file.

And delete this zip file. Now open public folder and move all file in public_html. So select all click on move. From path remove this public from here. And click on move.

Now open index.php file and make changes

<?php

use Illuminate\\Contracts\\Http\\Kernel;
use Illuminate\\Http\\Request;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the \"down\" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists(__DIR__.'/storage/framework/maintenance.php')) {
require __DIR__.'/storage/framework/maintenance.php';
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

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

$kernel = $app->make(Kernel::class);

$response = tap($kernel->handle(
$request = Request::capture()
))->send();

$kernel->terminate($request, $response);


Now add the database credential to the .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=databasename_here
DB_USERNAME=user_here
DB_PASSWORD=password_here


All done so lets check it
So go to the http://yourdomain.com/
And here you can see our e-commerce project is now live
So in this way you can deploy Laravel project on Shared Hosting.