Overview
This page details the steps required to setup a virtualhost for people that have a current webroot and do not want to lose their current (non-symfony) projects by adding the virtualhost directive, this problem is common when you are using a WAMP environment for development, and have an existing list of projects in c:/wamp/www that you want to keep using.
Step 1 : Create an internal host
Look for the host file on your computer, i found mine in c:/windows/system32/drivers/etc
This is what my old host file looked like :
# comment ... 127.0.0.1 localhost
Add a chosen virtual host, for askeet it would be
# comment ... 127.0.0.1 localhost 127.0.0.1 askeet
Step 2 : Add a virtualhost directive to httpd.conf
Look for the apache config (httpd.conf) i could found mine : C:\wamp\Apache2\conf\httpd.conf
Make sure the following line in your httpd.conf is not commented, or add it if you can't find it.
NameVirtualHost *:80
First we will add a virtualhost for the already existing, non-symfony projects located in c:/wamp/www (or somewhere else). If you forget this after enabling namevirtualhost in your apache config, apache will use the first virtualhost, and without the underlying virtualhost, that would mean that all projects listed in localhost/project1, localhost/project2 would point to your http://askeet chosen host, and thats not what we want right ?
<VirtualHost *:80> ServerName localhost DocumentRoot "C:\wamp\www" <== update with correct path DirectoryIndex index.php <Directory "C:\wamp\www"> <== update with correct path AllowOverride All Order allow,deny Allow from All </Directory> </VirtualHost>
After adding the virtualhost you need to add a virtualhost for your symfony project (added as internal host, step 1).
<VirtualHost *:80> ServerName askeet <== the chosen virtual host in step1 DocumentRoot "C:\wamp\www\symfony\web" <== update with correct path DirectoryIndex index.php Alias /sf "c:/wamp/php/PEAR/data/symfony/web/sf/" <== update with correct path <Directory "C:\wamp\www\symfony\web"> <== update with correct path AllowOverride All Order allow,deny Allow from All </Directory> </VirtualHost>
Restart your apache, no need to reboot.
apachectl -k graceful
Step 3 : Check out what you just did
and
http://localhost/projectX will point to your old 'non-symfony' projects.