centos環境下的apache 2.4虛擬主機的三種實現方法
吶,苦於沒法在生產環境使用apache,吶吶吶,虛擬機!
方法一:基於IP IP1:80 IP2:80 方法二:基於端口 IP:80 IP:8080 方法三:基於域名 IP:80 主機名不同 www.abcd.com www.efgh.com
一、基於IP 1、配置第二地址 [root@localhost~]#cd/etc/sysconfig/network-scripts/ [root@localhostnetwork-scripts]#cpifcfg-eth0ifcfg-eth0:0

[root@localhostnetwork-scripts]#servicenetworkrestart

2、配置http.conf,添加下面一行 #Virtualhosts Include/etc/httpd/extra/httpd-vhosts.conf
3、配置httpd-vhosts.conf

4、建立網頁目錄a.org及zjj

5、新建網頁文件

6、用elinks打開網頁 [root@localhosthtdocs]#elinkshttp://192.168.1.135

[root@localhosthtdocs]#elinkshttp://192.168.1.136

二、基於端口(注意:iptables放行8080端口) 1、修改httpd.conf

2、修改httpd-vhosts.conf

3、新建網頁目錄及網頁文件

4、測試[root@localhosthtdocs]#elinkshttp://192.168.1.135

[root@localhosthtdocs]#elinkshttp://192.168.1.135:8080

三、基於域名 看到空白的,肯定要嫌我懶了。。基於域名基本與前面一直,只要修改hosts文件,能讓域名解析到即可。