Are you reading the Zend Framework quickstart tutorial and you are blocked at “Create a virtual host“?
It’s really simple, here I explain how to do it in Ubuntu GNU/Linux (versione 10.04 LTS).
First you have to choose the hostname for you virtual host. It’s the first part of the URL you use to access the vhost. For example you can choose myapp.mycomputer. You have to add this row to /etc/hosts :
In this way you say “myapp.mycomputer domain is mapped to 127.0.0.1, the local host”.
Add a virtual host
Now you create the vhost directory where files for your application goes
$ sudo mkdir /var/www/myapp
And now create the file where you define the vhost (The one with … in the tutorial), create the file /etc/apache2/sites-available/myapp.mycomputer with this content :
<VirtualHost *:80> ServerName myapp.mycomputer DocumentRoot /var/www/myapp SetEnv APPLICATION_ENV "development" <Directory /var/www/myapp> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
In particular note the lines with ServerName, DocumentRoot and <Directory …> (In case of a Zend Framework application DocumentRoot and <Directory …> should point to the public directory of it).
Enable the vhost and enjoy it!
Now you have to do the last few little things:
Enable the vhost
$ sudo ln -s /etc/apache2/sites-available/myapp.mycomputer /etc/apache2/sites-enabled/myapp.mycomputer
UPDATE (2010/09/04) : The right way to enable it is use the e2ensite command that will create that link for you:
$ sudo a2ensite myapp.mycomputer
$ sudo /etc/init.d/apache2 restart
Open your favourite browser and go to http://myapp.mycomputer/
This knowledge comes from the OSys R&D department :P.