Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Although Ulrich answer pretty much the same as this, I ticked this as the answer because it is more detailed. –  Eric Feb 22 '12 at 1:25
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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 '12 at 7:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.