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