Recommended workflows for Apache virtual hosts?
When I had to do shuch things I proceed creating a VirtualHost whit a wildcard name:
- Choose a fancy domain name like 'example.com' for localhost
- Place it in
/etc/hosts
file as127.0.0.1 *.example.com
- Install and activate
mod_rewrite
-
create a wildcard VirtualHost in apache sites directory:
<VirtualHost 127.0.0.1:80> DocumentRoot /default/path ServerName example.com ServerAlias *.example.com RewriteEngine On UseCanonicalName Off RewriteCond %{HTTP_HOST} ^(.*).example.com RewriteCond /srv/%1/ -d RewriteRule ^(.+) %{SERVER_NAME}$1 [C] RewriteRule ^([^.]+)\.example\.com/(.*) /srv/$1/$2 [L] </VirtualHost>
Now you can place any folder under
/srv/
and it will be the root for<foldername>.example.com
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.
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.