This document attempts to answer the commonly-asked questions about setting up virtual hosts.
These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.
The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names http://www.example1.com/ and http://www.example2.org/ respectively. In each case, we want to run hosts on ports 80 and 8080.
##############################################
Server configuration
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName http://www.example1.com/
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName http://www.example1.com/
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName http://www.example1.org/
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName http://www.example2.org/
</VirtualHost>
##############################################
These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.
The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names http://www.example1.com/ and http://www.example2.org/ respectively. In each case, we want to run hosts on ports 80 and 8080.
##############################################
Server configuration
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName http://www.example1.com/
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName http://www.example1.com/
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName http://www.example1.org/
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName http://www.example2.org/
</VirtualHost>
##############################################
No comments:
Post a Comment