apache 403 forbidden 錯誤解決方法

apache 403 forbidden 錯誤解決方法2008-08-25 15:33                                                            Selinux限制了訪問。可以用
           # chcon -u system_u -t httpd_sys_content_t -R 目錄
           爲http訪問增加權限

問 題的解決的辦法是針對特定的目錄和文件使用 chcon 來給文件貼個標籤(這樣說應該還算合適吧,正式的說法應該是 security context)。先用 ls -Z 看能正常訪問的位置的文件和目錄的標籤,比如 /var/www 是 system_u:object_r:httpd_sys_content_t,然後使用

chcon -R -h -t httpd_sys_content_t

來貼標籤。-R 是遞歸,-h 不跟隨符號鏈接。這樣 apache 應該就可以訪問這個文件和目錄了。vsftpd 的解決辦法也是類似的。

比如:
           
           [root@monitor cci]# ls -Z /var/www/
           drwxr-xr-x root      root      system_u:object_r:httpd_sys_script_exec_t cgi-bin
           drwxr-xr-x root      root      system_u:object_r:httpd_sys_content_t error
           drwxr-xr-x root      root      system_u:object_r:httpd_sys_content_t html
           drwxr-xr-x root      root      system_u:object_r:httpd_sys_content_t icons
           drwxr-xr-x root      root      system_u:object_r:httpd_sys_content_t manual
           drwxr-xr-x webalize root      system_u:object_r:httpd_sys_content_t usage
           [root@monitor cc]# ls -Z /var/www/html/
           drwxr-xr-x root      root      root:object_r:root_t              cc
           -rw-r--r-- root      root      root:object_r:httpd_sys_content_t phptest.php
           [root@monitor cacti]# chcon -R -h -t httpd_sys_content_t /var/www/html/cc/


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章