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.

I have achieved setting up multiple virtual NIC in 1 VM, and bind websites to different IP on 1 server, e.g., access 2 websites by:

http://10.188.2.150
http://10.188.2.152    <--both IPs belong to the same server

The drawback is that in virutalbox, 1 VM can have 4 network card maximum.

Then, I am trying out the following: get 2 websites bind to the same IP address but different ports, so that I can access the 2 websites like this:

http://10.188.2.150:8003
http://10.188.2.150:8004

(I have checked that these 2 ports are not in use by 'lsof -i :[port]')

But I cannot access the website by opening, e.g. : http://10.188.2.150:8003

I set up my httpd.conf like this:

Listen 10.188.2.150:8003
Listen 10.188.2.152:8004

<VirtualHost 10.188.2.150:8003>
ServerName 10.188.2.150:8002
ServerAdmin admin@localhost
DocumentRoot /var/www/html/panda-web/html
<Directory /var/www/html/panda-web/html>
  AllowOverride All
</Directory>
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>

<VirtualHost 10.188.2.150:8004>
ServerName 10.188.2.150:8004
ServerAdmin admin@localhost
DocumentRoot /var/www/html/sheep-web/html
<Directory /var/www/html/sheep-web/html>
  AllowOverride All
</Directory>
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>

I've looked apache website but I must have missed something? Has anyone tried this?

share|improve this question
1  
Seems to have a typo between <VirtualHost 10.188.2.150:8004> and Listen 10.188.2.152:8004 –  Kdecherf Aug 28 '13 at 13:04
    
You also have a typo on the ServerName of the first VirtualHost –  Kdecherf Aug 28 '13 at 13:10
    
You don't need to have multiple instances of Apache to run more than one website on the same box. You can use host header recognition to do this with out all the IP level convolutions. –  TheFiddlerWins Aug 28 '13 at 13:14

2 Answers 2

But I cannot access the website by opening

Not a very meaningful analysis of the problem.

  • Have you checked if the webserver has the port open and is indeed listening for connection (using, e.g. netstat - BTW you forgot to mention what OS this is running on)?
  • Have you ried sniffing the packets going back and forth (e.g. using wireshark)?
  • Have you looked at your server logs?
share|improve this answer

You can have more than one IP address on a single network adapter, if that's your actual problem.

Getting back to your original Apache question, you should also tell us what version of Apache you are using. It won't probably matter for this specific question, but there could be minor o major differences between software versions...

For a generic introduction, I'd look at the Virtual Hosts guide in the Apache Documentation.

You can let Apache listen on different ports of the same IP Address: look into the Listen and VirtualHost directives.

You can also put two virtualhosts on the same IP:port, look into the NameVirtualHost and ServerName directives.

At the least, in your example you got the ServerName directives wrong. I suspect you didn't read or understood their documentation before wildly editing the config files.

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.