Search This Blog

Thursday, December 1, 2011

Setting Up Name Based Virtual Hosting In Ubuntu

1. Append the following line to your /etc/apache2/apache2.conf .
     NameVirtualHost 127.0.0.2:80
2 . Create unique files for each of my domains within the /etc/apache2/sites-available/ folder.Create a fie called mysitename.com

<VirtualHost 127.0.0.2:80>
ServerName 
mysitename.com
ServerAlias www.
mysitename.com
ServerAdmin me@ubuntu.com
DocumentRoot /var/www/mysitename/html
</VirtualHost>


3. Enable it by creating a symbolic link from one folder to the next ( etc/apache2/sites-enabled/)

sudo a2ensite mysitename.com ( to diable it anytime sudo a2dissite  mysitename.com)  

harder way to create the symbolic link 

cd /etc/apache2/sites-enabled/
ln -s ../sites-available/
mysitename.com .


4. Editing the /etc/hosts by adding the following line

127.0.0.2:80 mysitename.com 

5. Restart apache sudo /etc/init.d/apache2 restart

****

To enable mod_rewrite in Ubuntu, you just need to write this command in terminal

sudo a2enmod rewrite

No comments: