When I setup a new webserver (apache/mysql/nodejs/mongodb), I have the habit of storing every www-related asset (apache www-files, node js-apps, mysql/mongodb db files) into /srv/www
that I symlink to /home/srv
.
Did this in order to easily backup everything (since everything is in /home) and to store everything in a large isolated partition (usually 50G for / & everything else except swap to /home).
I've read that I could encounter some mounting issues doing this.
Is this considered bad practice?
mkdir --mode=0755 /home/srv; rm -rf /srv; ln -s /home/srv /srv && chown root:root /home/srv
mkdir --mode=0770 /srv/www; chown www-data:www-data /srv/www
Would you serve your IIS content from C:\Users?
The problem here is the semantic of the path.
/home
is well understood in unix to be a path containing users data, as such some systems make assumptions of the types of data in there (SELinux is a big one I can think of but this is less of a concern in Ubuntu).Other problems might arise if you did this and suddenly had a automount requirement for users, for example.
I would generally attempt to follow what is considered the 'norm' for the distro. Redhat tends to put service specific data in
/var/lib
.There are, of course grey areas here.
For the first point, personally if the users are nothing more than service users I would have their home directories point to a proper location for the document root of their website.
As for mod_userdir, this implies that it is a real user whom as a periphery has a web folder, so I would keep that web content in
/home
.Speaking from a 'sysadmin team' perspective; I think this kind of setup looks sloppy and disorganized at best, or lacking in competence at worst. You need to have good reasons to do something like this.
Purely as a matter of pride in your systems -- set them up to use paths that make some sense (and are not already pre-loaded with function). I think putting stuff in out-of-context locations is not a good way to organize your services.
Cant you just put all your data in another directory like
/var/lib
or/srv
? Frankly is it really that much of an effort to backup multiple paths?Meh, just provision
/var/lib
or/srv
as the big partition instead.I do not mean to sound harsh, but in my travels I have discovered that other people tend to get the hump when they see sysadmins doing things like this. I dont mean 'major problem alert' but it tends to be the thing you'll be remembered for that nobody told you about, which might end up discrediting you in the eyes of your peers.
"Bad Practice" is very much a relative thing.
On most Unix systems
/var/www
is "the directory that contains the main/default website", and/home/user/public_html
are the directories that are served when you go tohttp://example.com/~user
(viamod_userdir
).Generally speaking you should stick to that convention because it's what people expect.
If you can't follow that convention for some reason it's usually a good idea to symlink things so they at least seem to be where they're supposed to be, but you need to be aware of other factors (like SELinux) which might cause issues depending on how your server is configured.
As part of best practices you should also observe a sane partitioning scheme which will help you decide which partitions/sections of the disk get backed up, and how much space to throw at each of them.
In this sense I don't really agree with Mlfe's suggestion to "just provision
/var/lib
or/srv
as the big partition instead", or your layout of "50G for/
", a swap partition, and "everything else to/home
" -- You should determine the standard locations for things on your particular system (Ubuntu) using a reference like thehier
manpage, and then properly build your partition layout to support your particular needs.This avoids the situation Mlfe talks about where you implemented something nonstandard and are forever remembered as "The nitwit that put the web pages under
/home
" or something like that.