Enable "public_html" for users in Ubuntu for Apache2

To enable the “public_html” folder for users in Ubuntu using Apache2, you only have to follow 3 steps. These are:

  1. 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 userdir in a console. This command will add and/or enable the module.
  2. Create the public_html directory: Create the public_html directory in the users home Enter mkdir /home/a_user/public_html in a console.
  3. Restart Apache2: restart Apache2 so that the changes take effect. Enter sudo /etc/init.d/apache2 force-reload in 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

Leave a Reply