Adding User Directories to Virtual Hosts
10/3/2007
category:
technologyOn Apache 2.x, UserDir is now a module. When I say UserDir, I mean the ability of Apache to allow users on your server to have their own publicly available web space via a public_html (usually) directory. This space would be accessible with a URL similar to
http://<servername>/~<username>/.
I found it useful to enable the UserDir module on a virtual host. I didn't, however, want it available to all virtual hosts on that machine. Although unintuitive, it's pretty easy. Here's what you do:
- Instead of using
, you manually symlink the userdir.load file from your mods-available directory to your mods-enabled directory. That would look like this:a2enmod userdir . If you were to usesudo ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/ , that would symlink the userdir.conf file as well and we don't want that.a2enmod userdir - Now include the userdir.conf configuration file within your virtual
host configuration file. For example, my virtual host file is
. I add/etc/apache2/sites-enabled/dev.superiocity.com anywhere between theInclude /etc/apache2/mods-available/userdir.conf and<VirtualHost> elements.</VirtualHost> - Update your apache2.conf (or similar) file by adding:
on a line by itself. This will disable the UserDir module in all virtual hosts that don't have a specific configuration.userdir disabled - Lastly, don't forget to reload your configuration changes with
sudo /etc/init.d/apache2 reload