/var/www vs. /svr/www on Debian Wheezy

Hi. This is somewhat related to another post (/var/www/ vs. /home/user/public/mydomain.com/ ?), but I think it deserves its own thread.

The Linode LAMP guide for Debian Wheezy – https://www.linode.com/docs/websites/la … n-7-wheezy">https://www.linode.com/docs/websites/lamp/lamp-server-on-debian-7-wheezy -- says "All of the files for the sites that you host will be located in directories that exist underneath /srv/www."

But I've been using "/var/www" for forever. I'm curious whether continuing to use "/var/www" violates an Apache2 best practice? I searched and couldn't come up with a clear answer, and I value the opinions of this members/contributors of this forum.

Assume that the consensus is that using "/svr/www" is the best practice for Apache2. If I create a symbolic link from one directory to the other, would the link be created from the subdirectories under "/var/www" and linked into "/svr/www" or created in the subdirectories under "/srv/www" and linked into "/var/www"? (Or does it not matter so long as the link is created?)

Thanks.

Library Rat

5 Replies

It doesn't matter where you put your web files as long as all the config's point to that location.

@LibraryRat:

Thanks, vonskippy.

One reason that it might be better to use the /srv directory for websites is that you can have it on a separate partition and then only mount that partition with the options that you need. For instance you could set noexec, nodev and nosuid to improve security (only set noexec if you have no scripts, i.e your website is static). Having it on a different partition may also help with things like SELinux rules (although I'm not too sure on that). Also it will save you from accidentally filling up /var with log files and causing problems there.

Plus (and this is just personal opinion) I think keeping everything in /srv is cleaner.

Thanks, Cromulent. I guess that's where I'm coming from. It seems that consistently using one over the other is a best practice (for Apache2 as well as any other app). Just didn't know whether Apache2's "internal plumbing" required the use of /srv/www vs. /var/www. Your other point about using a separate partition definitely makes sense. Again, thanks.

@LibraryRat:

Just didn't know whether Apache2's "internal plumbing" required the use of /srv/www vs. /var/www.

There's nothing in Apache's "internal plumbing" that requires the DocumentRoot to be in any particular place. It's all controlled with configuration files in /etc/apache2. However, if the configuration files ever go missing or corrupt, Apache may revert to whatever is hardcoded into its source code, which usually coincides with the default DocumentRoot used by your Linux distribution. For Debian, that would be /var/www.

On the other hand, I usually avoid the distro-default path because it's often filled with junk that comes with the default installation, such as the "It works!" page, and depending on the distro, even a bunch of symlinks to things like phpmyadmin. You can delete that junk and add your website files instead, but if you ever need to reinstall Apache, the junk might come back :(

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct