首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

Apache虚拟主机设立(基于端口、IP、域名)

2012-08-27 
Apache虚拟主机设置(基于端口、IP、域名)一、相同IP不同端口(Port)的虚拟主机设置?? A: 增加监听端口????? #v

Apache虚拟主机设置(基于端口、IP、域名)

一、相同IP不同端口(Port)的虚拟主机设置
?? A: 增加监听端口
????? #vi {path}/httpd.conf
??? 由原来的
????? Listen 80
????? 改为
??? Listen 80
??? Listen 8080
??? 以上设置的含义为监听80与8080端口

? B: 更改虚拟主机设置:
? <VirtualHost 192.168.1.242:80>
? ???? ServerAdmin wmh188#126.com
??? ???? DocumentRoot /var/www/example.com
??? ???? ServerName 192.168.1.242
??? ???? ErrorLog logs/242-error_log
??? ???? CustomLog logs/242-access_log common
? </VirtualHost>
? <VirtualHost 192.168.1.242:8080>
? ???? ServerAdmin wmh188#126.com
??? ???? DocumentRoot /var/www/example2.com
??? ???? ServerName 192.168.1.242
??? ???? ErrorLog logs/242-error_log
??? ???? CustomLog logs/242-access_log common
? </VirtualHost>


二、相同端口(Port)不同IP的虚拟主机设置
? A: 为主机配置不同的IP地址:
???? #cd /etc/sysconfig/network-scripts
???? #cp ifcfg-eth0 ifcfg-eth0:1
???? #vi ifcfg-eth0:1
???? 将eth0:1更改为:
???? DEVICE=eth0:1
?????? BOOTPROTO=static
?????? BROADCAST=192.168.1.255
?????? HWADDR=00:0C:29:46:3B:0B
?????? IPADDR=192.168.1.243
?????? NETMASK=255.255.255.0
?????? NETWORK=192.168.1.0
?????? ONBOOT=yes
?????? 注:以上为作者的测试环境,根据自己的情况,只需更改DEVICE与IPADDR的值即可。
???? #service network restart

? B:更改虚拟主机设置
??? <VirtualHost 192.168.1.242:80>
? ???? ServerAdmin wmh188#126.com
??? ???? DocumentRoot /var/www/example.com
??? ???? ServerName 192.168.1.242
??? ???? ErrorLog logs/242-error_log
??? ???? CustomLog logs/242-access_log common
? </VirtualHost>
? <VirtualHost 192.168.1.243:80>
? ???? ServerAdmin wmh188@126.com
??? ???? DocumentRoot /var/www/example2.com
??? ???? ServerName 192.168.1.243
??? ???? ErrorLog logs/242-error_log
??? ???? CustomLog logs/242-access_log common
? </VirtualHost>


三、不同域名的虚拟主机设置
??? A:更改虚拟主机设置
? <VirtualHost *:80>
? ???? ServerAdmin wmh188#126.com
??? ???? DocumentRoot /var/www/example.com
??? ???? ServerName www.example.com example.com
??? ???? ErrorLog logs/example.com-error_log
??? ???? CustomLog logs/example.com-access_log common
? </VirtualHost>
? <VirtualHost *:80>
? ???? ServerAdmin wmh188#126.com
??? ???? DocumentRoot /var/www/example2.com
??? ???? ServerName www.example2.com example2.com
??? ???? ErrorLog logs/example2.com-error_log
??? ???? CustomLog logs/example2.com-access_log common
? </VirtualHost>

?

?

?

?

热点排行