<VirtualHost 192.168.1.100:80>
DocumentRoot /data/vhost/www1
ServerName www1.magedu.com
CustomLog /var/log/httpd/www1/aceess_log common
ErrorLog /var/log/httpd/www1/err_log##日志文件路径需要自己创建即可,否则启服务失败
<Directory "/data/vhost/www1">
options None
AllowOverride None
Order allow,deny
deny from 192.168.1.0 ###现在192.168.1.0网段中的任何主机都不可访问www1
</Directory>
<Location /server-status> ###设置访问www1.magedu.com/server-status的状态信息
SetHandler server-status
Order allow,deny
Allow from 192.168.1
AuthType Basic
AuthName "admin"
AuthUserFile "/etc/httpd/conf/.htpasswd"###用户认证文件
Require valid-user
</Location>
</VirtualHost>
SSLCertificateFile /etc/httpd/ssl/httpd.crt
------------------------------------分隔线---------------------------------------
二、centos7使用httpd2.4基于域名构建httpd服务
centos7上的httpd-2.4基本同centos6上的httpd2.2一样,所有有的地方就不详细的说明和操作了。
1、安装httpd服务
yum -y install httpd
2、创建网页及储存路径
mkdir -p /data/vhost/www{1,2}
echo "centos7 www1" > /data/vhost/www1/index.html
echo "centos7 www2" > /data/vhost/www2/index.html
<VirtualHost 192.168.1.104:80>
DocumentRoot /data/vhost/www1
ServerName www1.magedu.com
CustomLog /var/log/httpd/www1/acess_log common
ErrorLog /var/log/httpd/www1/err_log
<Directory "/data/vhost/www1">
Options None
AllowOverride None
##定义访问权限:
<RequireAll>
Require all granted
Require not ip 192.168
</RequireAll>
</Directory>
####定义状态页面并且认证
<Location "/server-status">
SetHandler server-status
Require all granted
AuthType Basic
AuthName "admin"
AuthUserFile "/etc/httpd/.htpasswd"
Require valid-user
</Location>
<VirtualHost 192.168.1.104:80>
DocumentRoot /data/vhost/www2
ServerName www2.magedu.com
CustomLog /var/log/httpd/www2/acess_log common
ErrorLog /var/log/httpd/www2/err_log
<Directory "/data/vhost/www2">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
----------------------------------分隔线-----------------------------------------
三、centos6编译安装httpd-2.4基于域名构建httpd服务
由于httpd-2.4所依赖的apr和apr-until需要1.4版本以上。而centos默认自带的版本比较低,所以我们在centos6使用httpd-2.4的时候需要我们手动进行编译安装才可以:
准备工具:apr-1.4.6.tar
apr-util-1.4.1.tar
httpd-2.4.6.tar