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 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
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 usea2enmod 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 addInclude /etc/apache2/mods-available/userdir.conf
anywhere between the<VirtualHost>
and</VirtualHost>
elements. - Update your apache2.conf (or similar) file by adding:
userdir disabled
on 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
Be First to Comment