Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to tests to sites locally.

It is good for me to have two configuration sections in Apache.

I tried

<VirtualHost 127.0.0.1>
    ...
</VirtualHost>


<VirtualHost 127.0.0.2>
    ...
</VirtualHost>

But when I type in browser 127.0.0.2, it shows the page from 127.0.0.1.

What is wrong and how can I resolve the issue?

Possibly the common practice is to change hosts.

share|improve this question
up vote 4 down vote accepted

Put your fake domain names into your /etc/hosts file and use name-based virtual hosting.

# /etc/hosts
127.0.0.1    example.com example.org example.net

# Apache httpd VirtualHost configuration
NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
  ServerName example.com
  # [...]
</VirtualHost>

<VirtualHost 127.0.0.1:80>
  ServerName example.org
  # [...]
</VirtualHost>

<VirtualHost 127.0.0.1:80>
  ServerName example.net
  # [...]
</VirtualHost>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.