Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can do this to set up a www directory from my home folder

gksu gedit /etc/apache2/sites-enabled/000-default

replace /var/www with /home/myusername/www

sudo service apache2 restart

But is there a way to use /home/$USER/www?

I don't want to use localhost/~myusername because it will mess up my code.

Basically I want to be able to login into different accounts on my laptop - one for work one personal - but have localhost default to the current logged in account.

Thanks, Russ

share|improve this question

No, you cannot do that. Apache is a system-wide web server, and Ubuntu is a multi-user system. Multiple users can be "logged in" at the same time, and Apache doesn't know anything about them.

You can however, simply set up multiple sites running on different ports, that point to different DocumentRoot directories on the machine.

share|improve this answer

You may be able to set an Environment Variable in the .bashrc script for each user, and then have the 000-default vhost access that environment variable. You'd have to restart /reload apache everytime you log in, but it might work. See This Answer for a little more information.

A simpler solution may be to set up more virtual hosts (use 000-default as a starting point) and edit your /etc/hosts file for local dns resolution.

share|improve this answer

Your Answer


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.