Strictly Programming

Setting up Virtual hosts in Apache HTTP Server 2

Posted in Uncategorized by sqllyw on 12/06/2008


Apache Virtual Host documentation

1. First, make sure you already have an Apache HTTP server running:
http://192.168.1.1

2. Now add following lines to your hosts file:

192.168.1.1 http://www.venus.com
192.168.1.1 http://www.mercury.com

try to do following, it will be pointing at the same site as what we did in #1.

http://www.venus.com
http://www.mercury.com

3. Create two document roots for the two virtual hosts
mkdir /var/www/venus.com
mkdir /var/www/mercury.com

put a index.html in each of the newly created directory

4. update httpd.conf as follow:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.venus.com
ServerAlias venus.com *.venus.com
DocumentRoot /var/www/venus.com
</VirtualHost>

<VirtualHost *:80>
ServerName www.mercury.com
DocumentRoot /var/www/mercury.com
</VirtualHost>

Restart your server, and try the commands in the step3, you will see the browser opens two different index.html in the step 4.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: