日期:2014-05-17  浏览次数:20745 次

php安装好以后 apache2 无法启动
在安装完成PHP后, 重新启动apache报如下错误
原因是Linux有一个SELinux保护模式引起的。
Syntax error on line 268 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
解决办法
1.编辑/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
保存,退出。

2.不关闭SELINUX的方法:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1