I have recently installed the Apache web browser in my Debian Squeeze (using command tasksel and selecting [ ] Web server). Now I get it to start via sudo /etc/init.d/apache2 start and then I go to my browser and key in http://localhost and the "It works!" page shows up indicating that I have installed and started the web server successfully.

Now I know that the HTML file for the "It works!" page is in /var/www and I am led to beleive that if I do create new pages, I need to stuff them into this directory. Creating pages would be easy but in doing so, I need to issue the sudo command each and every time I create/edit a file under the /var/www directory.

I would like to know how I can create a directory in my HOME e.g. ~/html/test/index.html and have that page displayed when I enter the address http://localhost/html/test in my browser address?

4 Answers 4


As Ulrich said, you can do this by enabling the userdir module.

On Debian, this can be done by using the a2enmod utility, which enables or disables Apache modules. See man a2enmod.

In this case, you just need to run

sudo a2enmod userdir

and then restart the Apache server to make the change take effect. Note that the userdir module is in base Apache, so you don't have to install anything extra. For reference the userdir config is in /etc/apache2/mods-available/userdir.conf.

All a2enmod is doing here is creating a symbolic link from the /etc/apache2/mods-enabled directory to the files /etc/apache2/mods-available/{userdir.conf/userdir.load}. You could also do this manually. I.e.

faheem@orwell:/etc/apache2/mods-enabled$ ls -la userdir.*
lrwxrwxrwx 1 root root 30 Feb  6 03:11 userdir.conf -> ../mods-available/userdir.conf
lrwxrwxrwx 1 root root 30 Feb  6 03:11 userdir.load -> ../mods-available/userdir.load

Then put whatever web stuff you want to make available under ~/public_html, and then it should be acccessible from http://servername/~username.

  • 1
    Although Ulrich answer pretty much the same as this, I ticked this as the answer because it is more detailed.
    – Eric
    Feb 22, 2012 at 1:25

You're probably looking for mod_userdir: "This module allows user-specific directories to be accessed using the http://example.com/~user/ syntax."

Don't be scared of fiddling with the config, just have backups of the config files and make sure your firewall blocks your apache to the outside world.

  • 2
    Thanks @Ulrich Schwarz, I think this is what I need. So, how do I set this up? I am not very familiar yet with Apache (only installed it now) and I don't know how to proceed with your suggestion.
    – Eric
    Feb 3, 2012 at 7:23

Personally I've used symbolic-links, depending of the project either to have link inside /var/www/ or /var/www itself being link to one of the folders in mine home directory (for example:~/projects/www). That way I can get rid of the "~" character. Sometimes it's also useful for me, when I want to show something to some other viewer (via something like:, and one's not that familiar with the keyboard, so he just couldn't find the "~" symbol from the keyboard (-kinda like looking for the key labeled "any").

Faheem and Ulrich probably cave you the best and most commonly recommended answer already anyway (at least, when security is concerned).

  • This is what I want to do, does it work well? Can you give the syntax for creating those links?
    – Menasheh
    Jan 19, 2017 at 19:13

Now you can do this by changing the web root, but you really don't want to, and here's why:

If an attacker finds a vulnerability in Apache, or in your code he may be able to gain access to the Web root. Which is where all your stuff is...

Web root is typically protected, with controls to stop attackers breaking out. Your home, possibly not quite so well secured.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .