Skip to content
Advertisement

Moving Laravel Core Files to private_html Directory

As a security precaution, my boss has requested I move my Laravel 7 app outside the public_html folder and into private_html.

So my directory structure looks like this:

JavaScript

Now, as expected since I moved the files, I’m getting an HTTP ERROR 500 when I visited the the website.

How do I tell Laravel where my public folder is so can get back to serving my web pages? Which configuration files do I need to edit?

Thanks for any help.

Edit 1: After trying Youssef’s suggestion, everything worked great except when I run

JavaScript

I get:

enter image description here

Edit 2:

I was able to fix “php artisan storage:link” by opening config/filesystems.php and changing:

JavaScript

To:

JavaScript

Then, when I type:

JavaScript

A new symlink is created.

Advertisement

Answer

In public/index.php change path of this two files to current path of them.

first line path of autoload.php

JavaScript

to

JavaScript

second line path of app.php

JavaScript

to

JavaScript

and put this in the AppProvidersAppServiceProvider register() method to set path of public directory.

JavaScript

finally reassign path of storage directory if you need access to stored files directly, using command :

JavaScript

you can also move all files from public_html/public to public_html and adjust paths I mentioned above

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement