Tuesday, March 2, 2010

Creating Virtual Host in Ubuntu

Specifying the Document Root for the Apache2 HTTP Server

The Document Root is the directory where the Apache HTTP server takes files for displaying in the browser. The Document Root is specified in the file that defines your virtual host. The default virtual host configuration file is 

with the document root 

We recommend that you create your own virtual host and enable it 
instead of editing the default one.

Creating the Document Root Location

  1. Choose Places > Home Folder.
  2. From the context menu, choose Create Folder.
  3. Enter the name of the folder, for example, public_html.

Creating a New Virtual Host

  1. To launch the Terminal, choose Applications>Accessories>Terminal. The Terminal window opens.
  2. To copy the configuration file of the default virtual host to a new file (mysite), type the following command at the command prompt:
    sudo cp /etc/apache2/sites-available/default 
  3. Run the gedit application and edit the new configuration file (mysite) in it:
    gksudo gedit /etc/apache2/sites-available/mysite 
    If asked, enter the password that you specified for the root user during the installation of your operating system.  
  4. Change the Document Root to point to the new location:
  5.  Change the Directory directive, replace

  1. Save the file mysite

Activating the New Virtual Host

  1. To deactivate the default host and activate the new host, launch the Terminal and run the following two utilities in the Terminal window:
    sudo a2dissite default && sudo a2ensite mysite
  2. Restart the Apache HTTP server:
    sudo /etc/init.d/apache2 restart


No comments:

Post a Comment