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.
- cd /etc/apache2/sites-available
- 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. - 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. - Enable your new virtualhost:
sudo a2ensite yourdomain.com.conf
- 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
Great and easy tutorial! Thanks a lot. But for virtual host to work, I needed to add “” instead of “”.
Ups – something went wrong in previous post. OK, again – I replaced * with *:80 to make it work.
Good tutorial!
Simple and direct!!
Trank’s
[…] Apache VirtualHost on Ubuntu | Tequila Fish (tags: ubuntu dns virtualhost) […]
nice & simple tutorial