Note: this tutorial has been tested on a shared hosting with CPANEL. Feel free to ask me on the comment section if you have other than CPANEL shared hosting services and this tutorial doesn't work.
Ok, here we go..
Step 1. Login to your CPANEL
CPANEL Login Form |
Make sure you entered the correct credentials. Most hosting companies will disable your account or block your IP address upon several consecutive login failure. The hosting company whom I subscribed to will block my IP address after my third failure login attempts.
If this actually happens, maybe because you forgot your password, just contact your hosting company. They will gladly help to solve your problem.
Step 2: Open the File Manager
After succesfully logged in to your CPANEL, you will find a lot of features displayed on your CPANEL dashboard. If you are new to CPANEL, don't be overwhelmed, just click on the File Manager button/icon.Step 3: Upload Files
We are going to do the upload in two parts. The first part is to upload all of files and folder, except the public directory, into the core directory we have created in the previous step. Use an FTP client and connect to your hosting service's FTP server. I like to use FileZilla, since it's free and seazy to use.Copy all but the public local direcotry to the remote core directory |
Once we are done uploading to the core directory, we will continue to the second part. Open the public directory on your local machine, and open the public_html directory on your remote server. Now upload all files and folders inside the public local directory to the public_html remote directory.
Upload all files inside public to public_html |
Remember, do not upload any files or folder outside the local public directory to public_html, because the public_html directory is accessible through the internet. If you accidentally upload, for example the .env file, then your database, SMTP, or any other crucial credentials might be exposed. Immediately change your credentials if this happens.
Also, according to the Laravel installation guide, you have to allow the storage and the bootsrap/cache directory to be writable and executable.
Step 4: Changing Permissions for storage and bootstrap/cache
To change permission for the the storage directory, do this:- Open the core directory.
- Right-click on the storage directory
- Click on the File Permission that shows up on the pop-up menu.
- Type in the lucky seven number (777) on the "Numeric Value" input box.
- Make sure that the "Recurse into subdirectories" checkbox is checked.
- Select the "Apply to all files and directories" radio button
- Click the OK button,
Right-clik storage, and click File Permissions |
Give all Read-Write-Execute permission recursively |
To change permission for the the bootstrap/cache directory, do this:
- Open the core directory, then get inside the bootstrap directory.
- Right-click on the cache directory
- Click on the File Attributes that shows up on the pop-up menu.
- Type in the lucky seven number (777) on the "Numeric Value" input box.
- Make sure that the "Recurse into subdirectories" checkbox is checked.
- Select the "Apply to all files and directories" radio button
- Click the OK button,
Right-click bootstrap/cache, and select File Attributes |
Give all Read-Write-Execute permission recursively |
Step 5: Edit the index.php File
Since we separate the application into two directories, core and public_html, we need to tell Laravel that some directories are no longer in their default location. The way we tell this fact to Laravel is to open the index.php file located inside the public_html directory.From the CPANEL file manager, click the public_html directory on the left directory tree panel. Then on the file lists on the right, click on the index.php file.
Next click the Edit button somewhere on the upper menu.
Next, find this line:
require __DIR__.'/../bootstrap/autoload.php';and change it to become like this
require __DIR__.'/../core/bootstrap/autoload.php';Similarly, do the same for this line:
$app = require_once __DIR__.'/../bootstrap/app.php';and change it to become like this
$app = require_once __DIR__.'/../core/bootstrap/app.php';