0

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.

sergtk
  • 113
  • 8

1 Answers1

4

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>
joschi
  • 20,747
  • 3
  • 46
  • 50