Every Zend Framework project starts with creating a virtual host for the project. For me as a developer using virtual hosts has several advantages. The biggest advantage, I guess, is that working with virtual hosts feels like working on a live project. Instead of using the URL http://localhost/www.project.com the developer uses the URL http://alpha.project.com. Different states of development can be detached to the URL. So it only costs a quick view to know on which development level a developers is working. Thereby I advice to use the key words alpha (project is under construction and saved local), beta (project is ready for testing and savedon line) and www (project is ready and saved on line) for the different states of development. The following tutorial now shows how I set up a virtual host in Windows XP using Zend Server CE as a local web server.

  1. Browse to C:\Programme\Zend\Apache2\conf\ and open the file httpd.conf.
  2. Place the following part at the end of the file:
    NameVirtualHost *:80
  3. Now, let’s create a bypass for localhost requests:
    <VirtualHost *:80>
        DocumentRoot C:\Programme\Zend\Apache2\htdocs
        ServerName localhost
    </VirtualHost>
  4. After creating the localhost bypass we can create the project based virtual host:
    <VirtualHost *:80>
        DocumentRoot C:\Programme\Zend\Apache2\htdocs\www.project.com
        ServerName alpha.project.com
        DirectoryIndex index.php
        <Directory "C:\Programme\Zend\Apache2\htdocs\www.project.com">
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
            AllowOverride All
        </Directory>
    </VirtualHost
  5. Save the file httpd.conf and close it.
  6. Browse to C:\WINDOWS\system32\drivers\etc and open the file hosts.
  7. Here you’ll find the following entry:
    127.0.0.1    localhost
  8. Add the following entry at the end of the file:
    127.0.0.1    alpha.project.com
  9. Save the file hosts and close it.
  10. After you have restarted your Apache web server you can enjoy your virtual host.

Additional informations

, , , , ,
Trackback

no comment untill now

Add your comment now