How to Upload Laravel on a Subdomain Through cPanel

Laravel is one of the open source PHP frameworks with the MVC design (Model-View-Controller) that is used to build website applications. There is a different directory structure  between ordinary Laravel files and website files.

For this reason, to upload laravel files to Hosting, especially for subdomains, it can run smoothly, so you must change the directory structure first.

In this example, we will upload laravel files on the subdomain.
The steps to upload Laravel on subdomains are as follows:

  1. Adjust directory structure

The following is the original directory on the local computer:

First create a new folder with the name “sublaravel”, and move all files and folders to the “sublaravel” folder except the public folder. Directory after being changed as follows:

Then change the name of the “public” folder to “blog” because we will upload it on the subdomain (adjust to the name of our subdomain) as shown below:

Next Edit the file “blog / index.php” which initially looks like the following picture:

Changed the source code to the following image:

For laravel 4, edit the file “sublaravel / bootstrap / paths.php” to the following:

For Laravel 5, re-edit the file “blog / index.php” and add the source code below:

// set the public to this directory
$ app-> bind (‘path.public’, function () {
return __DIR__;

Become like the following:

After editing the source code, the index.php file is complete, we save the index.php file and return to the local computer. Change the “blog” folder and the “sublaravel” folder on the computer into one .zip file first as shown below:

2. Upload laravel on subdomains

In the preparation stage, we have changed the Laravel file directory. There are only 2 folders, namely the “blog” folder and the “sublaravel” folder and one zip file. Now it’s time to upload one of these zip files to hosting, especially for subdomains. We will upload via cPanel. We first enter cPanel> file manager> public_html then rename or delete the “blog” folder on the hosting. For example we will change the name of the “blog” folder to blog_kkk shown in the picture as follows:

Then we upload the zip file to cPanel> file manager> public_html like the following picture:

After the zip file has been uploaded, right-click the file and extract it in the public_html folder as shown below:

Display after being uploaded and extracted in the public_html folder as follows:

Finally we try to access the subdomain in the browser and the results are as shown below:

Thus the guide to uploading files on a subdomain. Hopefully useful and good luck.

Leave a Reply

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