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:
- Open your terminal and login as root
- Go to apache directory, in Ubuntu default setting it would be in /etc/apache
- Now you need to install userdir module, type this command to install:
- Then now edit the file userdir.conf, it would be in /etc/apache/mods-enabled directory
- 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>
- 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/
- Back to root terminal, then restart apache with this command:
- 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.