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 do a lot of local web development work on my Ubuntu machine, and I'm constantly setting up virtual hosts in Apache. I don't need to do hard core server management, but I am getting tired of the repetitive process of manually adding config directives to files in /etc/apache2/sites-available/ and then updating the /etc/hosts file.

Is there a more efficient or more automated way to do all this that I'm missing? Maybe something like rapache but that's actually working?

share|improve this question
up vote 8 down vote accepted

When I had to do shuch things I proceed creating a VirtualHost whit a wildcard name:

  1. Choose a fancy domain name like '' for localhost
  2. Place it in /etc/hosts file as *
  3. Install and activate mod_rewrite
  4. create a wildcard VirtualHost in apache sites directory:

      DocumentRoot /default/path
      ServerAlias *
      RewriteEngine On
      UseCanonicalName Off
      RewriteCond %{HTTP_HOST} ^(.*)
      RewriteCond /srv/%1/ -d
      RewriteRule ^(.+)   %{SERVER_NAME}$1 [C]
      RewriteRule ^([^.]+)\.example\.com/(.*) /srv/$1/$2 [L]
  5. Now you can place any folder under /srv/ and it will be the root for <foldername>

This is borrowed from memory, it could need some more minor adjustments and it may conflict with any other rewrite rules each webapp would have. But it fits me for my webapp testing needs.

share|improve this answer
That's very clever, will give it a try. Thanks. – craig zheng Feb 21 '11 at 22:49
Great answer. Except the wildcard didn't work for me, I had to use dnsmasq for get it to work. – elias Aug 1 '12 at 17:57

would webmin work ? It's not just for apache but rather a web interface to system administration. It does have a form filling interface to apache virtual host.

share|improve this answer
Looked into webmin but thought it might be overkill, you know? – craig zheng Feb 21 '11 at 22:50

why not make a website that makes/updates the files for you? if you are working with php and this is local only use the exec() function to run terminal commands to write/create/update data that you want based on textbox entries. I wish i knew how to make applications on ubuntu that are gui based. would make life really easy.

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.