On a system (in my case Ubuntu server) with multiple users where each user is permitted to have their own home directory, you need to install mod_userdir on your Apache. So you can have an address like this: www.anyurl.com/~username/. Each user will have their own subdirectory specified by the UserDir directive in the configuration.
Installing the userdir module in Apache on Ubuntu server is not hard. It only needs a couple of steps and a directory permission change.
Follow these steps below:
1. Open your terminal and log in as root.
2. Go to the Apache directory. In Ubuntu’s default setting it would be in /etc/apache.
3. Now you need to install the userdir module. Type this command to install:
a2enmod userdir
4. Then edit the file userdir.conf. It would be in the /etc/apache/mods-enabled directory.
5. Copy and paste this setting:
<ifModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<directory /home/*/public_html>
#AllowOverride FileInfo AuthConfig Limit Indexes
suPHP_Engine on
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec FollowSymLinks
<limit GET POST OPTIONS>
Order allow,deny
Allow from all
</limit>
<limitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</limitExcept>
</directory>
</ifModule>
6. Up to this step, you have already activated the userdir module. Now open another terminal with a normal user. Then create public_html in the home directory. Then change the directory group owner to www-data with this command:
chgrp www-data public_html/
7. Back to the root terminal, then restart Apache with this command:
/etc/init.d/apache restart
8. Now open your browser and type: http://localhost/~username/ — you should see “It Works” if you got it right.
That’s it for now. Leave me any comment if you find this article helpful or if you want to ask anything. Thank you for visiting and have a nice day.
