Datasheet
10
Chapter 1: You: Programmer and Search Engine Marketer
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot “C:/Program Files/xampp/htdocs”
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot C:/seophp/
ServerName seophp.example.com
<Directory C:/seophp/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
4. To make sure httpd-vhosts.conf gets processed when Apache starts, open xampp\apache\
conf\httpd.conf
and make sure this line, located somewhere near the end of the file, isn’t
commented:
# Virtual hosts
include conf/extra/httpd-vhosts.conf
5. Restart Apache for the new configuration to take effect. The easiest way to restart Apache is to
open the XAMPP Control Panel, and use it to stop and then start the Apache service.
In case you run into trouble, the first place to check is the Apache error log file. In the default XAMPP
installation, this is
xampp\apache\logs\error.log.
6. To test your new virtual host, create a new file named test.php in your seophp folder, and
type this code in it:
<?php
phpinfo();
?>
7. Then load http://seophp.example.com/test.php and expect to see a page like the one in
Figure 1-6.
This way you’ve also tested that your PHP installation is working correctly.
In order for http://localhost/ to continue working after you create a virtual host,
you need to define and configure it as a virtual host as well — this explains why
we’ve included it in the vhosts file. If you have any important applications working
under
http://localhost/, make sure they continue to work after you restart
Apache at the end of this exercise.
00929c01.qxd:00929c01 3/13/07 10:38 AM Page 10