-1

I'm used to setting up client websites in /home/clientusername/ with subdirectories such as webapps/, html/, cgi-bin/, logs/ etc. (for both Apache and NGINX) so clients can manage their own files, from their user directory, under their user/group.

However, there seems to be no clear guidance on where to situate user directories containing websites for Linux web servers (Debian in this case) and /var/www/website_01/ etc. seems to be out there as a "default" location.

Only a few clients need to manage their own websites in user-specific directories, so what would be the correct location on a Debian server for user-specific directories (e.g. /home/clientusername/html/) to host each client's web files? Not looking for opinions, just facts!

2 Answers 2

0

This depends on permissions. With using the /var/www/website method, you might end up messing with the permissions badly so that apache or NGINX might error out. If you are creating users on the server for clients, going for your method might be the better option. If you do not plan to setup unix users for the clients, it might not be a good option. Also, you might end up messing with the permissions of the /home directory because some web server will need permission to the root of the folder.

2

Usage of /var/www is confusing only at first sight.

According to the FHS, web server data should go to /srv. That is the main rule.

However, it also says that deciding about the structure of /srv is the sole responsibility of the local administrator! Therefore packages must not put anything into /srv, and the default document root must not be /srv, because the (apache) package does not know what is in /srv and below it. Maybe a subversion repository with clear text password and other things as well. So there must be a default outside of /srv. That default become /var/www.

/var/www is mostly a placeholder. Packages use /usr/share for static HTML content, or /var/lib for dynamic variable content. Many people mistakenly thought that they should then put HTML into /var/www. That is a problem, because packages occasionally use that too. So recently they invented /var/www/html for packages. Hopefully people will not start to use that because then again they have to invent a new directory... and so on.

Summary: you should use /srv and configure your Apache virtual hosts accordingly.

2
  • So to enable unix users to log in and manage their own files to serve on the web, I'd have something like /srv/unsername/users_web_files/ for each user? Jun 23, 2020 at 14:02
  • 1
    @DaveEveritt I use /srv/www as the base directory as SELinux recognizes this path and sets contexts correctly. Not a big issue if you are running Debian and not SELinux, but things other than web sites can be in /srv as well (FTP sites, NFS shares, anything you might share). Jun 23, 2020 at 14:15

Not the answer you're looking for? Browse other questions tagged .