Run httpd with SELinux

我实在不理解 SELinux,以前为了求简单,都是直接 disable SELinux。我也知道这样不好,可以没办法。

最近重装系统,第一次选 Web Server 来装,我想这样搭配出来的 SELinux 最接近我的要求。可是,但我添加了 zend.repo 以后,发现 httpd 无法启动,错误信息为:

# service httpd start
Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/zendserver_php.conf: Cannot load /usr/local/zend/lib/apache2/libphp5.so into server: /usr/local/zend/lib/apache2/libphp5.so: cannot enable executable stack as shared object requires: Permission denied
                                                           [FAILED]

我按论坛上的建议,执行了

# find /usr/local/zend/lib/ -name "*.so*" -exec semanage fcontext -a -t textrel_shlib_t {} \;

错误仍在。然后按 SELinux 的建议,执行了

# setsebool -P httpd_execmem 1

呵,成了。因为我不会 undo # find /usr/local/zend/lib/ -name “*.so*” -exec semanage fcontext -a -t textrel_shlib_t {} \; 所以我不知道此命令是否必要。

Leave a comment

Your email address will not be published. Required fields are marked *