Upload Laravel Project To Shared Hosting or Server

Published on April 15, 2019 1 min read

HIRE US 🖐
We're available to do freelance project. Take a look at our services!

We can easily make Laravel project live in shared hosting or server. Let’s follow these steps:

Table of Contents

  1. Compress Project Files
  2. Upload Zip Files to Hosting
  3. Extract Zip Files
  4. Config index.php
  5. Note For Server

Step 1 : Compress Project Files

Go to your Laravel project directory. We need to make two zip files. Make one zip file without public folder and named as ‘framework.zip’. Then navigate to public folder and zip the contents as ‘public.zip‘.

Project files and folders:

Public folder:

Step 2 : Upload Zip Files to Hosting

Login to your web hosting CPanel and navigate to the root folder. Normally for all shared hosting the root folder is public_html. Then upload the zip files using File Manager.

Uploaded zip files:

Step 3 : Extract Zip Files

Now right click on ‘public.zip‘ file and Extract it.

After extracting public.zip, make a folder named “framework” and move the framework.zip file to that directory. Then extract framewrok.zip like public.zip. After extracting, delete those zip files.

So, the file structure look likes:

Step 4 : Config index.php

We are about to finish. Now we need to modify two lines (24 & 38) of the index.php. Open index.php and change like this:

index.php
-----
require __DIR__.'/framework/vendor/autoload.php';

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

That’s it. Now just visit your website URL to see the project. 🙂

Note For Server

For the server, you need to do the same things. You can connect to your server using FileZilla and follow those steps. You can also unzip easily via SSH.

Login to your server using SSH. Then go to the root directory and type this command to unzip:

unzip filename.zip

If zip, unzip not installed on your server, type this to install zip, unzip:

# CentOS
sudo yum install zip unzip

# Ubuntu
sudo apt-get install zip unzip
We are done. Thank you. 🙂

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.
Author

Hey, I'm Md Obydullah. I build open-source projects and write on Laravel, Linux server, modern JavaScript and more on web development.

Follow

4 Replies to “Upload Laravel Project To Shared Hosting or Server”

  1. Hello, i have used this to get laravel on my site but when i go to a different page than home it shows a 404 error, do you know how to fix this problem?

Leave a Reply

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