Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Now apache is listening on hostA,how to make it also listen on hostB too?

I've already pointed hostA and hostB to 127.0.0.1

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

In advance

If you point hostA and hostB to 127.0.0.1 you will only be able to connect to the server from localhost. (Just wanted to put a finger on it, from now on I assume this is your intention)

Now to your question

If you would like to use two different adresses pointing to one directory you will look for something like

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName hostA
    ServerAlias hostB www.hostA www.hostB
    DocumentRoot /www/domain
</VirtualHost>

Otherwise if you would like to use different document roots (also known as name based virtual hosting) you will need to use something like this:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName hostA
    ServerAlias www.hostA
    DocumentRoot /www/hostA
</VirtualHost>

<VirtualHost *:80>
    ServerName hostB
    ServerAlias www.hostB
    DocumentRoot /www/hostB
</VirtualHost>
share|improve this answer
add comment

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.