Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm running CentOS 5.6 on my server with Apache. I need to create a "staging" site so that client can view the development in progress. I understand that this is done via Apache virtual host. Where is this file located on the server?

Since we have 1 IP address on the test server, and we don't want to change DNS for the domain name just yet, how do I setup the virtual host to resolve the http://my.ip.addy to our test server's /var/www/html/public directory?

Thanks much for your guidance.

share|improve this question
It sounds like you need multiple domains going to different sites while using the same IP, right? – Rilindo Oct 3 '11 at 20:31
Yes, I believe so. is needed right away, and eventually will be pointed to this server when dev/test is done. – SidC Oct 3 '11 at 20:35
up vote 1 down vote accepted

It sounds like you are trying to get a domain name to resolve to an IP as well as getting the computer at that IP to respond appropriately. To do that you want to modify your httpd.conf file, which is located at /etc/httpd/conf/ by default. You would then add the following at the bottom:

<VirtualHost *:80> # note the asterisk.
DocumentRoot /var/www/html/public
ErrorLog logs/

For ServerName you put whatever you want as a domain. Changing the *:80 to your.ip.add.ress:80 means that the machine will only respond by the ServerName provided if the request is to that IP (You may want that too, but I generally avoid it).

Then, on the client side, I would modify the hosts file to point that domain to the IP of the testing server. This will let you navigate to the domain and arrive at the testing site. It might be something like this:         localhost loopback
::1               localhost
share|improve this answer
On my hosts file, I have localhost our.ip.addy Do I need the entry ::1 localhost as well? When I browse to I am unable to resolve to the test server. Is there something else I need to do? – SidC Oct 3 '11 at 22:21
::1 is your IPv6 local host address. As for the other entry, you need to i has test Don't remove the existing local entry, to avoid breakage. – Rilindo Oct 3 '11 at 23:24

The configuration file is /etc/httpd/conf/httpd.conf and you can use the minimal virtualhost as follows,

<VirtualHost X.X.X.X:80>
DocumentRoot /var/www/html/public
ErrorLog logs/

More Info:

share|improve this answer
Will that allow us to hit the server via our.ip.address ? – SidC Oct 3 '11 at 20:55
Normally, the first virtualhost domain will be served when accessing the IP when you host multiple virtualhosts on the same IP. So, if there is only one virtualhost, I guess you got it :) – SparX Oct 3 '11 at 22:13

Your Answer


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.