Create a virtual host on ubuntu

Submitted by barnettech on

create a file: /etc/apache2/sites-available/cf_facultyportal.babsondrupal.org where the filename is the name of the url that will hit the webserver.

Put this in the file replacing the url and the file paths where appropriate:


<VirtualHost *:80>
  ServerName cf_facultyportal.babsondrupal.org
  DocumentRoot /var/www/cfannon_babson/babson/trunk/docroot
   <Directory /var/www/cfannon_babson/babson/trunk/docroot\>
      Options +Indexes +FollowSymLinks +ExecCGI
      DirectoryIndex index.php
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory\>
</VirtualHost>


Now, to enable the site you use the a2ensite command (Note:use a2dissite to disable). The following creates a symlink /etc/apache2/sites-enabled/mydomain.com, which enables the site.

$> a2ensite mydomain.com

You need to reload Apache to see the site...

$> /etc/init.d/apache2 reload

I also had this line in my /etc/apache2/apache2.conf file:

NameVirtualHost *:80

or these directions work: http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-ho…