100% working way Best Way to Deploying LARAVEL Project on Shared Hosting – Best Way to Host Laravel Website on Shared Hosting

How to Deploying Laravel Website/Project in Shared Hosting - Best Way to Host Laravel Website on Shared Hosting

Sharing is caring!

100% working way  Best Way to Deploying LARAVEL Project on Shared Hosting – Best Way to Host Laravel Website on Shared Hosting

Hello, Readers

I am back again with some new hacks. Yesterday I was wondering how to host simple LARAVEL application on shared hosting? And guess what I found a solution.

Let’s get started.

First of all let’s understand how LARAVEL app started, from public folder->index.php, right?

Now our first step is getting that index.php file to your Laravel root directory folder. You can find this 2 lines in your index.php file.

 

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

Change this both line to

require  'bootstrap/autoload.php';

$app = 'bootstrap/app.php';

And one more step is to get your .htaccess file from public folder to your Laravel root directory folder.

SO our Folder structure looks like this

How to host Laravel Website/Project in Shared Hosting - Best Way to Host Laravel Website on Shared Hosting
How to host Laravel Website/Project in Shared Hosting – Best Way to Host Laravel Website on Shared Hosting

 

And Done. Your Laravel project setup is completed for uploading in shared hosting.

Now One thing is to need to understand which is your assets. Add your css and js as you add in laravel before but now add “/public” in your asset URL.

// our assets are stored in public folder so we need to set it in the path

//for Css

<link href="{{ asset('public/assets/css/bootstrap.min.css')}}" rel="stylesheet">

//For Javascript
  <script src="{{ asset('public/assets/js/jquery.min.js')}}"></script>

 

Now one another question is how you can upload the vendor folder which contains more than 10000+ files. So here is the simple solution to make full LARAVEL Project ZIP file and extract it on your shared hosting panel.

100% working way Best Way to Deploying LARAVEL Project on Shared Hosting – Best Way to Host Laravel Website on Shared Hosting

Leave a Reply

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

Scroll to top