Tequila Fish Ran-dumb ramblings of me…

2Aug/07Off

Apache VirtualHost on Ubuntu

Here's a quickie tutorial on how to add Virtual Hosts to Apache on Ubuntu. This tutorial assumes that you have a basic understanding of Apache configuration and that your Apache is installed and able to serve websites.

  1. cd /etc/apache2/sites-available
  2. sudo vim yourdomain.com.conf and enter your VirtualHost directive. Below I've put the most basic example, see Apache docs for details and additional features:
    <VirtualHost *>
      ServerName yourdomain.com
      DocumentRoot /home/youruser/public_html
    </VirtualHost>

    Save & exit.
  3. sudo vim /etc/hosts and add your new domain to the 127.0.0.1 localhost line so it looks like this:
    127.0.0.1 localhost yourdomain.com
    Save & exit.
  4. Enable your new virtualhost:
    sudo a2ensite yourdomain.com.conf
  5. Reload the Apache configuration:
    sudo /etc/init.d/apache2 reload

That's it! Repeat for each of your VirtualHosts.

----------------
Now playing: Alèmayèhu Eshèté - Tchero Adari Nègn
via FoxyTunes

Comments (4) Trackbacks (1)
  1. Great and easy tutorial! Thanks a lot. But for virtual host to work, I needed to add “” instead of “”.

  2. Ups – something went wrong in previous post. OK, again – I replaced * with *:80 to make it work.

  3. Good tutorial!
    Simple and direct!!

    Trank’s

  4. nice & simple tutorial


Trackbacks are disabled.