Apache配置網站詳細說明web
1、關於Apache虛擬主機配置網站的幾種方法apache
一、基於IP地址的虛擬主機配置ide
在本機配置兩個IP地址,一個爲eth0, 一個爲eth0:1以下所配置網站
ifconfig eth0 192.168.100.177 netmask 255.255.255.0this
ifconfig eth0:1 192.168.100.48 netmask 255.255.255.0spa
同時,在cd /etc/sysconfig/network-scripts/ 下拷貝 eth0 而且命名爲eth0:1以下描述blog
DEVICE=eth0:1
BOOTPROTO=static
HWADDR=00:0C:29:9D:8A:17
ONBOOT=yes
IPADDR=192.168.100.48
NETMASK=255.255.255.0
GATEWAY=192.168.100.254ip
至此,回到apache的httpd.conf這個配置文件裏面去,看到如下配置文檔
配置本機一個IP地址,回到apache的httpd.conf的配置文檔需求表以下get
listen 8080
<VirtualHost 192.168.100.177:80>
ServerAdmin zhongyn@example123.com
DocumentRoot /var/www/website/bbs.example123.com
ServerName 192.168.100.177:80
Errorlog logs/bbs.err.log
CustomLog logs/bbs.access.log common
</VirtualHost>
<VirtualHost 192.168.100.177:8080>
ServerAdmin zhongyn@example123.com
DocumentRoot /var/www/website/blog.example123.com
ServerName 192.168.100.177:8080
Errorlog logs/blog.err.log
CustomLog logs/blog.access.log common
</VirtualHost>
三、基於虛擬主機的配置
NameVirtualHost 192.168.100.177:80
這個是虛擬主機的配置網站,前提是你要配置好你的虛擬主機頭,也就是配置好 DNS解析。
<VirtualHost 192.168.100.177:80>
ServerAdmin zhongyn@example123.com
DocumentRoot /var/www/website/bbs.example123.com
ServerName bbs.example123.com
Errorlog logs/bbs.err.log
CustomLog logs/bbs.access.log common
</VirtualHost>
<VirtualHost 192.168.100.177:80>
ServerAdmin zhongyn@example123.com DocumentRoot /var/www/website/blog.example123.com ServerName blog.example123.com Errorlog logs/blog.err.log CustomLog logs/blog.access.log common </VirtualHost>