Upload Laravel Project To Shared Hosting or Server
We can easily make Laravel project live in shared hosting or server. Let’s follow these steps:
Table of Contents
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:
-----
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.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.