Running multiple virtual hosts under Apache on Windows XP
This will be of no interest to most people but it's useful to note for future reference. The various click-installer solutions to set up Apache and PHP under Windows such as WAMP don't seem to automate the setup of virtual hosts, but it's fairly straightforward to do manually:
- Create the local directory structure for the new application somewhere useful, eg:
C:Documents and SettingsUserMy DocumentsProject Name - Add the new hostname in the Windows hosts file
C:WINDOWSsystem32driversetchosts, eg:127.0.0.1 localhost 127.0.0.1 project-name
- Edit the
httpd.conffile to include the virtualhost definitions at startup (The default WAMP install requires uncommenting this line and linking it to the correct file path), eg:# Virtual hosts Include "c:/wamp/apache2/conf/extra/httpd-vhosts.conf"
- In the
httpd-vhosts.conffile, specify the mapping from the project folder to the new hostname:NameVirtualHost * # this is the default mapping to http://localhost/
DocumentRoot C:wampwww ServerName localhost # the new virtual host mapping to http://project-name/DocumentRoot "C:Documents and SettingsUserMy DocumentsProject Name" ServerName project-name Options Indexes FollowSymLinks Includes AllowOverride All Order deny,allow Deny from all Allow from 127.0.0.1 DirectoryIndex index.php - Restart Apache and go...