How to configure local apache to support multiple local dev sites using wildcard subdomains?

Wednesday, July 2, 2014

I have many web projects under



[/var/www/personal]$ ls
project1 project2 app1 app2 hello index.php


I want visit these projects by access:



project.dev.me
project2.dev.me
app1.dev.me
app2.dev.me
hello.dev.me


and when I visit dev.me it goes to /var/www/personal/index.php


So far I've added this to my hosts:



dev.me 127.0.0.1


and enabled vhost_alias mod in apache config, and here's my virtual host configurations:



<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName dev.me
ServerAlias *.dev.me
VirtualDocumentRoot /var/www/personal/%1
<Directory /var/www/personal/>
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/dev.me.error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/dev.me.access.log combined
</VirtualHost>


But it doesn't work. I have two questions:


1) Can I get it work without adding every sub domain into my hosts file?


2) I can get the subdomains work if I add every sub domain into my hosts file, but what should I do to make dev.me point to index.php ?







http://ift.tt/1iUsVCt