Deploy Laravel 8 – Vue.js Application on Shared Hosting

Open terminal and run the command under your local folder

npm run prod

On shared host create new database for application.

Copy all files from Laravel  public folder to your hostings public_html folder

Create a folder in your hosting root (This will be out of the public_html.) and copy all application files (except public folder) into this folder. I named the folder as “LaravelCore”

Edit .env file.

Edit public_html/index.php as follows:

Find these lines

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

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

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

Change to :

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

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

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

In the file LaravelCore/app/Providers/AppServiceProvider.php add these lines in boot() function:

$this->app->bind('path.public', function() {
     return base_path().'/../public_html';
});

We are done! Now our application will run on share hosting.