在源码安装 apache 2.0.x 或 2.2.x 的时候,报错:
httpd: Syntax error on line 53 of /opt/apache/conf/httpd.conf Cannot load /opt/apache/modules/libphp5.so into server: /opt/apache/modules/libphp5.so cannot restore segment prot after reloc: Permission denied
一般会出现在 Redhat/RHEL/Fedora/CentOS 系统里,主要是因为 redhat 公司的 SELinux 在捣鬼。
解决办法有两个:
1. 使用chcon 命令
示例: chcon -t texrel_shlib_t /your apache installed path/modules/libphp5.so
实例: chcon -t texrel_shlib_t /your apache installed path/modules/*.so
2. 禁止掉SELinux
更改/etc/sysconfig/selinux 文件的内容为 SELINUX=disabled,重启系统