Virtual host configuration in Ubuntu 13.04
Now a days I am learning symfony framework.
While installation I came across the need to configure the virtual host on my ubuntu.
Here is what I found on the Ubuntu online documentation.
In Apache2 ships with a virtual-host-friendly default configuration. That is, it is configured with a single default virtual host (using the VirtualHost directive) which can modified or used as-is if you have a single site, or used as a template for additional virtual hosts if you have multiple sites. If left alone, the default virtual host will serve as your default site, or the site users will see if the URL they enter does not match the ServerName directive of any of your custom sites. To modify the default virtual host, edit the file /etc/apache2/sites-available/default.
I needed to configure virtual host for my symfony.dev application.
My document root for the symfony project was /var/www/symblog.dev
Now we need to cony the default virtual host file from the
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/symblog.dev
Edit the new file named symblog.dev to configure the new site using some of the directives described below.
NameVirtualHost 127.0.2.1 <VirtualHost 127.0.2.1> ServerName symblog.dev DocumentRoot "/var/www/symblog.dev/web" DirectoryIndex app_dev.php <Directory "/var/www/symblog.dev/web"> AllowOverride All Allow from All </Directory> </VirtualHost>
The ServerName directive is optional and specifies what FQDN your site should answer to. The default virtual host has no ServerName directive specified, so it will respond to all requests that do not match a ServerName directive in another virtual host.
Enable the new VirtualHost using the a2ensite utility and restart Apache2:
sudo a2ensite symblog.dev sudo service apache2 restart
Be sure to replace symblog.dev with a more descriptive name for the VirtualHost. One method is to name the file after the ServerName directive of the VirtualHost.
Similarly, use the a2dissite utility to disable sites. This is can be useful when troubleshooting configuration problems with multiple VirtualHosts:
sudo a2dissite symblog.dev sudo service apache2 restart