(5)使用自定Web根目录

调整 Web 站点 http://server0.example.com 的网页目录,要求如下:

1) 新建目录 /webroot,作为此站点新的网页文件根目录
# mkdir /webroot
# echo '<h1>wo shi Webroot' > /webroot/index.html

2) 修改配置文件/etc/httpd/conf.d/nsd01.conf
<VirtualHost *:80>
ServerName server0.example.com
DocumentRoot /webroot #修改网页文件根目录
</VirtualHost>

3) 追加写入 /etc/httpd/conf.d/nsd02.conf
<Directory "/webroot">
Require all granted #允许所有
</Directory>

4)SELinux安全上下文(标识,标签)
– chcon [-R] --reference=模板目录 新目录

# ls -Zd /webroot/ #查看目录标签值

# chcon -R --reference=/var/www /webroot/
# ls -Zd /webroot/

5) 重起httpd服务

6)测试

[root@server0 webroot]# curl server0.example.com
<h1>wo shi Webroot

posted @ 2021-05-29 22:27  落樰兂痕  阅读(169)  评论(0编辑  收藏  举报