Friday, December 11, 2009

[Linux] CentOS的apache設定with selinux

安裝好CentOS,啟動httpd後,在/var/www/html下建了新目錄後,browse時會發現:
403 Forbidden
到error_log去看,會發現:
(13)Permission denied: access to /search/ denied

解法方法:
方法1
# vi /etc/sysconfig/selinux
SELINUX=enforcing --> SELINUX=disabled

# reboot

方法2
# ls -Z
drwxr-xr-x apache apache user_u:object_r:user_home_t search

# sudo chcon -R -h -t httpd_sys_content_t search


要連線遠端的mysql時,error_log會出現:(遠端的mysql帳號,密碼,權限設定都沒問題)
Can't connect to MySQL server on '192.168.0.9'

解法方法:
# sudo setsebool -P httpd_can_network_connect_db 1
# sudo service httpd restart


用curl時,command line正常,但在httpd下,卻出現:
curl error no 7
Permission denied

解決方法:
# sudo setsebool -P httpd_can_network_connect 1
# sudo service httpd restart



Reference:
http://blog.roodo.com/saycheese/archives/1600863.html
http://wiki.ubuntu.org.cn/index.php?title=Quick_HOWTO_:_Ch20_:_The_Apache_Web_Server/zh&variant=zh-hant

No comments:

Post a Comment