To enable the “public_html” folder for users in Ubuntu using Apache2, you only have to follow 3 steps. These are:
- Add the Apache2 userdir module: In Ubuntu, this functionality comes as a default module for Apache2. If you don’t have it enabled, just enter
sudo a2enmod userdirin a console. This command will add and/or enable the module. - Create the public_html directory: Create the public_html directory in the users home Enter
mkdir /home/a_user/public_htmlin a console. - Restart Apache2: restart Apache2 so that the changes take effect. Enter
sudo /etc/init.d/apache2 force-reloadin a console.
After Apache2 finishes restarting, you will be able to access the user’s public_html directory entering the address as follows in a web browser (I.E. Firefox :D) http://localhost/~a_user
Cheers