Entry
How to set up virtual host without having server name (only IP)?
Nov 16th, 2001 14:18
Anthony Boyd, Andreas Boehmer,
If you can't use domain names, you can run many virtual servers by
using a new port for each one. Set up the VirtualHost in httpd.conf as
usual, but note how my example specifies port 8080:
<VirtualHost 127.0.0.1:8080>
ServerAdmin webmaster@mysite.com
DocumentRoot /usr/local/apache/mysite
ServerName www.mysite.com
ErrorLog logs/mysite-error_log
TransferLog logs/mysite-access_log
</VirtualHost>
You also need to add a Listen line to the httpd.conf file (Listen
lines usually appear near the end of the file), like this:
Listen 8080
And then save the file and restart the server. In your browser,
type http://127.0.0.1:8080/ to get at the "other" site.
Don't forget: if you're going to add many virtual hosts at different
port numbers, be SURE to add a Listen line for each port. I always
forget that part, and I always feel silly when I realize it's missing.