Monday 21 May 2012

Create Virtual Host on Ubuntu

Install
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:
3. <VirtualHost *>
4. ServerName yourdomain.com
5. DocumentRoot /home/youruser/public_html
6. </VirtualHost>
7. Save & exit.
8. sudo vim /etc/hosts and add your new domain to the 127.0.0.1 localhost line so it looks
like this:
9. 127.0.0.1 localhost yourdomain.com
10. Save & exit.
11. Enable your new virtualhost:
12. sudo a2ensite yourdomain.com.conf
13. Reload the Apache configuration:
14. sudo /etc/init.d/apache2 reload

Remove

Code:
sudo a2dissite sitename
Restart apache2
Code:
sudo /etc/init.d/apache2 reload
Again to remove (delete)it completely from the system,
Code:
sudo rm /etc/apache2/sites-available/sitename
I would also disable it first before deleting the file.

No comments: