Virtual Host on Apache2 [Ubuntu Lucid]
- gedit /etc/apache2/apache2.conf
ServerRoot "/etc/apache2"
ServerName ... --> whatever you like eg. ServerName CzEmpire
- Set Apache's ports > gedit /etc/apache2/ports.conf
#Listen for virtual host request on all IP addresses at port 80
NameVirtualHost *
#Listen on port 80
Listen 80
- Create virtual host
> cd sites-available
#Create first virtual host named "localhost" eg. http://localhost
> gedit localhost
#Specify where "localhost" directory locates
DocumentRoot /var/www/localhost
#Specify name for this virtual host
ServerName localhost
ServerAdmin xxx@xxx.xxx
- Enable virtual host configuration
> a2ensite localhost
> a2ensite www.abc.com
- Create web site repository
> cd /var/www
> mkdir localhost/htdocs
> mkdir localhost/logs
> mkdir localhost/cgi-bin
> mkdir www.abc.com/htdocs
> mkdir www.abc.com/logs
> mkdir www.abc.com/cgi-bin
- Make your server know all previous domain names
> gedit /etc/hosts
127.0.0.1 localhost www.abc.com
- Restart system
- Start Apache2 engine
> /etc/init.d/apache2 start