Fedora Core 2開始就已經有了SELinux (Security-Enhanced Linux )這個東西,不過在 FC2下是預設不開啟的,從FC3開始就預設開啟了,但是開啟了是很安全,但是很多操作也不能操作了。
比如再FC4下裝Apache + PHP,手工編譯的,但是去無法解析PHP,看錯誤提示,都是什麼:
[root@localhost ~]# /usr/local/apache/bin/apachectl start Syntax error on line 232 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp4.so into server: /usr/local/apache/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
鬱悶了,總是無法載入libphp4.so這個包,想了半天沒有結果,搜尋一下,原來是SELinux再搞鬼,哼,把你給關了。
使用vi/gedit/kate/bluefish任何的文本編輯工具開啟 /etc/selinux/config,找到這段:
找到這段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 注釋掉:#SELINUX=enforcing ,然後新加一行為:
SELINUX=disabled
儲存,關閉。
然後再使用文本編輯工具開啟:/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
如果SELINUX已經是 SELINUX=disabled,那麼就不用改了,否則就把SELINUX=enforcing 注釋掉,新加一行:
SELINUX=disabled
儲存,退出。
重啟系統,然後看看我們的Apache已經能夠運行PHP了。呵呵。
如果你碰到其他類似提示:
cannot restore segment prot after reloc: Permission denied
哪應該是SELinux的問題,可以考慮把它關閉。