How to set up a virtual host on Apache2 in Ubuntu Gutsy Gibbon (7.10)
- 0 Comments
If you're new here, you may want to start with my most popular posts. Then, subscribe to my RSS feed to stay updated. Thanks for visiting!
Earlier, I showed you “How to install a lamp stack on Ubuntu Gutsy Gibbon (7.10).” This will get you started with the default website. However, for day to day development work, I find it easier to work on sites (Wordpress, Ruby, etc.) in my Home directory so I don’t have to sudo every time I edit a file.
For this you will need to set up a virtual host in Apache2. Think of it as a separate web site that runs in your Home directory. I followed the write-up at the Community Ubuntu Documentation. In order to set this up, follow the summary below.
-Create a new directory for your new site like the below by typing the following in the Terminal
mkdir /home/yourusername/public_html/
-Copy the default site to use as a starting template by typing the following command in the Terminal:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/yournewsite
-Edit the configuration file by typing the following command in the Terminal:
gksudo gedit /etc/apache2/sites-available/yournewsite
-Look for the following in the configuration file:
DocumentRoot
-Point “DocumentRoot” to a new location by deleting the current location path and entering a new one such as:
/home/yourusername/public_html/
-Look for the following in the configuration file:
<directory /var/www/>
-Replace the above line with:
<directory /home/yourusername/public_html/>
-Save and close the configuration file.
-Deactivate the old site and activate the new site with a2ensite and a2dissite by typing the following in the Terminal:
sudo a2dissite default && sudo a2ensite mysite
-Restart Apache2 by typing the following in the Terminal:
sudo /etc/init.d/apache2 restart
-Test the new site by typing the following into the Terminal:
echo '<b>Searchmarked.com is the coolest site on the web!</b>' > /home/yourusername/public_html/index.html
That’s it! You should be able to display the test site in the browser by navigating to http://localhost or http://127.0.0.1 Happy Web Hosting!
Technorati Tags: Ubuntu, Apache, LAMP
Related posts:
- How to install a LAMP stack on Ubuntu Gutsy Gibbon (7.10)
- How to work around the gray Tilda window bug in Ubuntu Gutsy Gibon (7.10)
- How to install the free ($) VMWare Server in Ubuntu Gutsy Gibbon (7.10)
- How to be more productive with the Ubuntu Gutsy Gibbon (7.10) Terminal using Tilda
- How to get past the `require’: no such file to load — mkmf (LoadError) when installing the “mysql” gem


