[精讚] [會員登入]

SELINUX 中網頁放在家目錄

家目錄中要放網頁,SELINUX中該如何設定?

分享完整連結 //n.sfs.tw/m10695

分享連結 SELINUX 中網頁放在家目錄@精讚
(文章歡迎轉載,請尊重版權註明連結來源)
2020-12-20 01:29:02 By 張○○

/var/www/html 中預設是 httpd_sys_content_t 類型

當然,你把家目錄設成這個類型,肯定能正常操作。

但是不建議,最好把你的家目錄類型設定成:

  httpd_user_content_t
  httpd_user_rw_content_t

例如 john 的家目錄

 unconfined_u:object_r:user_home_dir_t:s0  123 Dec 19 11:31 john
     ∟ unconfined_u:object_r:httpd_user_content_t:s0 250 Dec 19 11:26 public_html/  <== 提供上網的目錄
     ∟ unconfined_u:object_r:httpd_home_t:s0 250 Dec 19 11:26 other/  <== 不提供上網的目錄

提供上網的目錄設定成 httpd_user_content_t

最後要用 setsebool 把家目錄的開關打開

# setsebool httpd_enable_homedirs on
# setsebool httpd_enable_homedirs on -P

另外對於CGI的程式,例如 perl的程式,要另開一個開關:

AH01241: error spawning CGI child: exec of '/home/path/to/cgi.pl' failed (Permission denied): /home/path/to/cgi.pl

那麼cgi的程式就要把他的 TYPE改為 httpd_user_script_exec_t (不是httpd_sys_script_exec_t)

chcon -t httpd_user_script_exec_t cgi.pl

 

參考資料

[1] https://serverfault.com/questions/691501/apache-permission-denied-exec-of-var-www-html-cgi-test-first-pl-failed

END
你可能有興趣

[Rocky9] 安裝node.js 18, node.js 20

原本的nodejs16在使用 quasar dev時出現錯誤,得升級成18版以上

[SSL] Could not read certificate from server.cer 的錯誤排除

在轉換ssl憑證時,出現無法讀取的錯誤,可是怎麼看憑證都很正常,該怎麼解決?

[Linux] 如何能知道我是什麼時候安裝系統的?

linux想知道什麼時候裝系統的? 不必憑記憶。

地圖填色的網站

我們想為國家填色不需要小畫家,這個網站能幫助你

[Linux] 列出所有目錄及所占空間的方法

想知道目錄下的所有目錄所占的空間大小?

[Linux] grep 排除特定字串

使用 -v 參數可以讓grep排除特定字串的方法