Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Installation & Hosting

Installing Grav outside of document root

Started by dinomed 5 years ago · 4 replies · 684 views
5 years ago

Hi there,

I want to store only the necessary files (index.php, images, css, js, media files etc.) in the document root folder which are served by http server directly and everything else (sources, configs etc.) outside of it.

Is it possible by changing only the paths of directories in index.php? It would affect the command line tools?

Thanks in advance! 🙂

5 years ago

@dinomed, Unless symlinking or one of these scenarios is what you are after, I have no idea...

Curious about what you are trying to achieve though...

5 years ago

I guess this kind of practice is to protect the source code. Lots of frameworks have such approach as the default AFAIK.

I guess with Grav the whole /user folder would still have to stay in root, because it holds all the content related to each page (like attached files and images, or theme and plugin assets, etc.)

5 years ago

Some frameworks and Content Management Systems do, usually to protect resources because they're otherwise exposed in an untoward manner. Grav itself (Core) has no such resources. And all source code is public already, much the same as with most frameworks and CMS'.

The "outside-root" approach really only holds value if there are protected resources available, and they should be protected by other, more robust, means in that case. If the resources exist it's because they need to be exposed to the website, otherwise they shouldn't be stored on the webserver. As suggested, symlinking would allow you to move these files and folders pretty much anywhere on the server.

If you just want less clutter in root, install Grav in a subdirectory.

👍 1
5 years ago

I think it's a good practice to keep out unnecessary files from root, especially when configs are stored in plain text files. Maybe someone removes accidentaly the htaccess file... or removes the blocking... or something else. That way at least site site wide settings are not exposed.

Another good reason for that is that you can achieve easily multisite (subdomain) functionality with subdomains for example and you need to apply security patches/updates/upgrades to only once.

Anyway, thanks for the answers! :)

Suggested topics

Topic Participants Replies Views Activity
Installation & Hosting · by antoinep, 13 hours ago
5 60 8 hours ago
Installation & Hosting · by Jürgen Dietrich, 7 months ago
0 62 7 months ago
Installation & Hosting · by rappluk, 8 months ago
0 62 8 months ago
Installation & Hosting · by N, 12 months ago
3 72 12 months ago
Installation & Hosting · by Youle, 1 year ago
1 61 1 year ago