I'd like to deploy a Laravel 5 app to a subdirectory of my web server root (public root being /public_html in this case as we're using Apache). The web server already has a non-Laravel site in the root public folder.
Most questions on this topic come down to using a subdomain instead of a subdirectory, however as we're using an organisational SSL cert without subdomain coverage we cannot do this.
I realise we could still plop the non-public resources above public_html, the public resources in a subdirectory and then hack at the paths required, but I haven't found any concrete instructions for how to achieve this. Is there a standard approach for this use case?
You can create a sub-folder as public_html/new_project (or whatever name you give as per your coding conventions). And create another folder on the same level as the public_html for non-public resources as eg: new_project_resources.
public folder from your laravel project and upload it to the new_project_resources folder (on server). public folder of your laravel project and copy everything and upload it to the public_html/new_project folder (on server). Now open index.php file from public_html/new_project and
Change:
require __DIR__.'/../bootstrap/autoload.php';
To:
require __DIR__.'/../../new_project_resources/bootstrap/autoload.php';
And
Change:
$app = require_once __DIR__.'/../bootstrap/app.php';
To:
$app = require_once __DIR__.'/../../new_project_resources/bootstrap/app.php';
Save and Close.
Now go to new_project_resources folder and open server.php file
Change:
require_once __DIR__.'../public/index.php';
To:
require_once __DIR__.'../public_html/new_project/index.php';
Save and close.
Things should work now from the subfolder. Hop it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With