On 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
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
a2enmod userdir, you manually symlink the userdir.load file from your mods-available directory to your mods-enabled directory. That would look like this:
sudo ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/. If you were to use
a2enmod userdir, that would symlink the userdir.conf file as well and we don’t want that.
- Now include the userdir.conf configuration file within your virtual host configuration file. For example, my virtual host file is
/etc/apache2/sites-enabled/dev.superiocity.com. I add
Include /etc/apache2/mods-available/userdir.confanywhere between the
- Update your apache2.conf (or similar) file by adding:
userdir disabledon a line by itself. This will disable the UserDir module in all virtual hosts that don’t have a specific configuration.
- Lastly, don’t forget to reload your configuration changes with
sudo /etc/init.d/apache2 reload