We all want to have local directories in Apache so we can write and test code safely. Here’s how to do it

1. Create a directory in your home called public_html

2. Install the userdir Apache module using the a2enmod command like so

sudo a2enmod userdir

3. Edit the Apache 2 user preferences configuration file at /etc/apache2/httpd.conf

sudo vi /etc/apache2/httpd.conf

4. Put the following in the config file

<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

5. Now restart Apache like so

sudo /etc/init.d/apache2 force-reload

6. You should now be able to browse your public_html directory from a web browser at the following URL:

http://localhost/~<username>/


Leave a Comment