Multiple Apache VirtualHosts and Users

I've done some searching, but I haven't found an answer to this question:

Should each VirtualHost have it's own user account?

Ie: www.foo.com has user foocom; www.bar.com is tied to user barcom

Or is this unnecessary and more complicated than it's worth?

5 Replies

Depends on how it is setup.

I have a lot of virtual hosts which are owned by nobody. Since they have their own content management and users are in the website not at the unix level.

If you have users that need to ftp/scp content to them, then they most likely have some ownership of the site.

@Dweeber:

Depends on how it is setup.

I have a lot of virtual hosts which are owned by nobody. Since they have their own content management and users are in the website not at the unix level.

If you have users that need to ftp/scp content to them, then they most likely have some ownership of the site.

How does one set up a VH to be owned by nobody?

The only one that's going to be doing any ftp/scp is me, and I've created a separate user account for myself already. I wasn't too keen on the idea of having all the website files created under my userspace as that didn't seem wise.

Right now I only have the one domain which is my playground; but I plan on adding at least one more to test out some ideas I've had.

Do it all the time.

drwxr-xr-x  7 nobody  nogroup  4096 May 10 22:47 acils
drwxr-xr-x 36 cumuls  nogroup  4096 May 22 20:41 cumuls
drwxr-xr-x 14 nobody  nogroup  4096 May 22 07:06 droid
drwxr-xr-x  3 nobody  nogroup  4096 May 12 11:44 junk
drwxr-xr-x  3 nobody  nogroup  4096 May 22 07:23 lists
drwxr-xr-x 10 nobody  nogroup  4096 May  6 16:21 milkyrobot
drwxr-xr-x  8 nobody  nogroup  4096 May 22 07:23 oacil
drwxr-xr-x 11 nobody  nogroup  4096 Mar 11 09:25 rc
drwx------  2 root    root     4096 May 19 13:49 .retired
drwxr-xr-x 13 nobody  nogroup  4096 May 22 07:24 sww
drwxr-xr-x 10 nobody  nogroup  4096 May 22 07:24 tef
drwxr-xr-x 35 nobody  nogroup  4096 May 22 07:06 tnet
drwxr-xr-x  5 nobody  nogroup  4096 May 10 16:38 tnetly
drwxr-xr-x 11 nobody  nogroup  4096 May 22 07:24 tnetsupport
drwxr-xr-x 13 nobody  nogroup  4096 May 22 07:25 ulterius
drwxr-xr-x 66 wetter  nogroup 12288 May 22 20:41 wetter
drwxr-xr-x 14 nobody  nogroup  4096 May 22 07:25 worms

The only thing a virtual host needs really is DNS which is a cname to the host. The only two above are weather related sites and they have users that "own" them so that data can be SCP'd to them.

Making a new vhost…

o Create dns for new hosts.

o cd /www/vhosts/

o mkdir somename

o scp content to the somename directory OR copy blank wikiweb to directory.

o set permissions

o add entry to /www/etc/virtualhosts

o restart webserver

o done. Start access to do whatever.

Typically takes longer for the DNS change to take place than setting up the site.

All of my virtual vhosts can be moved from host to host. those that use a database, need an export and import but I have a lot of wiki based sites that dont use a database and are like content management systems built in.

@Dweeber:

Do it all the time.

drwxr-xr-x  7 nobody  nogroup  4096 May 10 22:47 acils
drwxr-xr-x 36 cumuls  nogroup  4096 May 22 20:41 cumuls
drwxr-xr-x 14 nobody  nogroup  4096 May 22 07:06 droid
drwxr-xr-x  3 nobody  nogroup  4096 May 12 11:44 junk
drwxr-xr-x  3 nobody  nogroup  4096 May 22 07:23 lists
drwxr-xr-x 10 nobody  nogroup  4096 May  6 16:21 milkyrobot
drwxr-xr-x  8 nobody  nogroup  4096 May 22 07:23 oacil
drwxr-xr-x 11 nobody  nogroup  4096 Mar 11 09:25 rc
drwx------  2 root    root     4096 May 19 13:49 .retired
drwxr-xr-x 13 nobody  nogroup  4096 May 22 07:24 sww
drwxr-xr-x 10 nobody  nogroup  4096 May 22 07:24 tef
drwxr-xr-x 35 nobody  nogroup  4096 May 22 07:06 tnet
drwxr-xr-x  5 nobody  nogroup  4096 May 10 16:38 tnetly
drwxr-xr-x 11 nobody  nogroup  4096 May 22 07:24 tnetsupport
drwxr-xr-x 13 nobody  nogroup  4096 May 22 07:25 ulterius
drwxr-xr-x 66 wetter  nogroup 12288 May 22 20:41 wetter
drwxr-xr-x 14 nobody  nogroup  4096 May 22 07:25 worms

The only thing a virtual host needs really is DNS which is a cname to the host. The only two above are weather related sites and they have users that "own" them so that data can be SCP'd to them.

Making a new vhost…

o Create dns for new hosts.

o cd /www/vhosts/

o mkdir somename

o scp content to the somename directory OR copy blank wikiweb to directory.

o set permissions

o add entry to /www/etc/virtualhosts

o restart webserver

o done. Start access to do whatever.

Typically takes longer for the DNS change to take place than setting up the site.

All of my virtual vhosts can be moved from host to host. those that use a database, need an export and import but I have a lot of wiki based sites that dont use a database and are like content management systems built in.

This is probably going to sound stupid, but what I actually meant is do I need to create a user "nobody"? Or is there a system default that I can use?

This is my first foray into running my own web server from the ground up, but not entirely my first foray into using Linux. There are some things I'm fine with and others that are totally foreign, so I apologize if it seems like I already ought to know.

On this server, the web server is running as the user nobody using the group nogroup.

If you are using Linux, you most likely already have those on your box.

However, the key is to use what the default web server uses when it runs.

Typically, it is started by root, but then switches to a non-root account for security. In an Apache httpd.conf file the user it uses is typically listed like:

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup

PM sent.

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