httpd服务

         练习:        (1)基于主机名实现三个虚拟主机

                       (2) 每虚拟主机使用独立的访问日志和错误日志

                       (3) 第三个虚拟主机的/admin要进行用户访问认证

                       (4) 在第二个虚拟主机上提供/status

                       (5) 在第三个虚拟主机提供路径别名/bbs,访问其它文件系统路径;

                       (6) 尝试使用混合类型的虚拟主机:

                            基于IPPORTServerName

<VirtualHost 10.1.72.30:8080>

DocumentRoot "/var/www/html/www1/"

CustomLog "logs/www1_access_log" combined

ErrorLog "logs/www1_error_log"

ServerName www1.wang.com

<Directory "/var/www/html/www1">

options None

AllowOverride None

Require all granted

</Directory>

</VirtualHost>

blob.png

<VirtualHost 10.1.72.22:8080>

DocumentRoot "/var/www/html/www2/"

ServerName www2.wang.com

CustomLog "logs/www2_access_log" combined

ErrorLog "logs/www2_error_log"

<Directory "/var/www/html/www2">

options None

AllowOverride None

Require all granted

</Directory>

<Location /status>

SetHandler server-status

Require ip 10.1.72.30

</Location>

</VirtualHost>

blob.png

<VirtualHost 10.1.72.30:80>

DocumentRoot "/var/www/html/www3/"

ServerName www3.wang.com

CustomLog "logs/www3_access_log" combined

ErrorLog "logs/www3_error_log"

<Directory "/var/www/html/www3">

options None

AllowOverride None

Require all granted

</Directory>

<Directory "/var/www/html/www3/admin">

options None

AllowOverride None

AuthType Basic

AuthName "This is a private area plesae input user and password"

AuthUserFile "/etc/httpd/conf/.htpasswd"

Require user wang

</Directory>

Alias /bbs/ "/data/"

<Directory "/data">

options None

AllowOverride None

Require all granted

</Directory>

</VirtualHost>

blob.png

blob.png

blob.png

原创文章,作者:landanhero,如若转载,请注明出处:http://www.178linux.com/49697