Apache启动出错:Cannot load /usr/local/apache/modules/libphp5.so

Apache启动出错:Cannot load /usr/local/apache/modules/libphp5.so

在CentOS平台,安装httpd-2.4.6和php-5.3.27,一切顺利,最后一步重新启动Apache报如下错误:

1 [root@localhost modules]# service httpd start

2 启动 httpd:httpd: Syntax error on line 149 of /usr/local/apache/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

解决方案:

第一步:修改Apache目录权限

1 chown -R apache:apache /usr/local/apache

第二步:关闭SELinux

(1).关闭SELINUX的方法:

vim /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled ,需要重启系统

1 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

(2).不关闭SELINUX的方法:

#先临时关闭SELINUX

1 setenforce 0

#修改规则

1 chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

#重启Apache

1 service httpd restart

#重新开启SELINUX

1 setenforce 1