To securely use laravel on shared hosting, it’s important to separate the public folder. This secures the environment file etc.
- Create a folder outside of your public_html folder, called application.
- To this newly created folder you upload all but the public folder to. This is where your app, resources, storage etc. will now be located.
- Go to your public_html folder, and upload the contents of your public folder.
- Edit the file called index.php and locate this piece of code.
And replace it with the following.
Do the same for bootstrapping, replace the below.
$app = require_once __DIR__.'/../bootstrap/app.php';
With the following.
$app = require_once __DIR__.'/../application/bootstrap/app.php';
- At last go back to the application folder, and edit the permissions of the storage folder by right clicking. Set permissions recursively to 777. This folder is for cache, files, logs etc. and must be accessible by the system.
The application is now secure.
Last update: 2018-05-21 20:20:57
Read more about Laravel