- 編輯 httpd 配置檔,將 DocumentRoot 改到 /mnt/deyu1。
[root@kvm7 ~]# vim /etc/httpd/conf/httpd.conf
[root@kvm7 ~]# grep -A5 ^DocumentRoot /etc/httpd/conf/httpd.conf
DocumentRoot "/mnt/deyu1"
<Directory "/mnt/deyu1">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
- 重新啟動 httpd 服務。
[root@kvm7 ~]# systemctl restart httpd.service
- 在 SAMBA server 的 /groupdir 目錄下新增 index.html。
[root@kvm5 ~]# cal > /groupdir/index.html
- 查看 /mnt/nfsmount/index.html 的 SELinux contexts 為
cifs_t。
[root@kvm7 ~]# ls -Z /mnt/deyu1/
-rw-r--r--. root root system_u:object_r:cifs_t:s0 file1
-rw-r--r--. root root system_u:object_r:cifs_t:s0 file2
-rw-r--r--. root root system_u:object_r:cifs_t:s0 index.html
- curl 訪問網頁,回傳沒有權限存取。
[root@kvm7 ~]# curl http://127.0.0.1/index.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /index.html
on this server.</p>
</body></html>
- index.html 的 SELinux context 是
cifs_t,必須開啟 httpd_use_cifs 布林值,查看此布林值目前是 off。
[root@kvm7 ~]# getsebool -a | grep httpd_use_cifs
httpd_use_cifs --> off
- 開啟
httpd_use_cifs 布林值。
[root@kvm7 ~]# setsebool -P httpd_use_cifs on
[root@kvm7 ~]# getsebool -a | grep httpd_use_cifs
httpd_use_cifs --> on
- curl 再訪問網頁,成功回傳網頁內容。
[root@kvm7 ~]# curl http://127.0.0.1/index.html
October 2019
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31