January 8, 2010 by Ivan
[HowTo] Make Apache User Directory on Ubuntu
On system (in my case is Ubuntu server) with have multiple user and each user permit to have their own home directory, then you need to install mod_userdir on your apache. So you can have the address like this: www.anyurl.com/~username/. Each user will have their own subdirectory specified by UserDir driective in the configuration.
To install userdir module in apache on ubuntu server is not hard. Only need a couple steps and change directory permission. Follow these steps below:
1. Open your terminal and login as root
2. Go to apache directory, in Ubuntu default setting it would be in /etc/apache
3. Now you need to install userdir module, type this command to install:
a2enmod userdir
4. Then now edit the file userdir.conf, it would be in /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 already activate userdir module. Now open another terminal with normal user. Then create public_html in home directory. Then change the directory group owner to www-data, with this command:
chgrp www-data public_html/
7. Back to 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 is helpful or if you want to ask anything. Thank you for visiting and have a nice day.




