设为首页 收藏本站
查看: 962|回复: 0

[经验分享] apache php selinux

[复制链接]

尚未签到

发表于 2018-11-26 14:13:38 | 显示全部楼层 |阅读模式
centos 5.0
selinux 为开启状态
apache 2.2.8
php 5.0

安装完成之后,apache无法加载php模块。错误如下:
httpd: Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: API module structure 'php5_module' in file /usr/local/apache2/modules/libphp5.so is garbled - expected signature 41503232 but saw 41503230 - perhaps this is not an Apache module DSO, or was compiled for a different Apache version?


相信提示大伙都能看懂。网上有解决办法就是关闭selinux 下面讲另二种方法
一:按提示操作:(大体意思是将libphp5.so加入selinux系统内)

#tail /var/log/messages
May 23 10:08:15 nagios setroubleshoot:      SELinux is preventing /usr/local/apache2/bin/httpd from loading /usr/local/apache2/modules/libphp5.so which requires text relocation.      For complete SELinux messages. run sealert -l e693621e-145b-4431-bdcb-68b3883f1ac8



# sealert -l e693621e-145b-4431-bdcb-68b3883f1ac8
Summary
    SELinux is preventing /usr/local/apache2/bin/httpd from loading
    /usr/local/apache2/modules/libphp5.so which requires text relocation.

Detailed Description
    The /usr/local/apache2/bin/httpd application attempted to load
    /usr/local/apache2/modules/libphp5.so which requires text relocation.  This
    is a potential security problem. Most libraries do not need this permission.
    Libraries are sometimes coded incorrectly and request this permission.  The
    http://people.redhat.com/drepper/selinux-mem.html web page explains how to
    remove this requirement.  You can configure SELinux temporarily to allow
    /usr/local/apache2/modules/libphp5.so to use relocation as a workaround,
    until the library is fixed. Please file a
    http://bugzilla.redhat.com/bugzilla/enter_bug.cgi against this package.

Allowing Access
    If you trust /usr/local/apache2/modules/libphp5.so to run correctly, you can
    change the file context to textrel_shlib_t. "chcon -t textrel_shlib_t
    /usr/local/apache2/modules/libphp5.so"

    The following command will allow this access:
    chcon -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so

Additional Information        

Source Context                user_u:system_r:unconfined_t
Target Context                system_u:object_r:lib_t
Target Objects                /usr/local/apache2/modules/libphp5.so [ file ]
Affected RPM Packages         
Policy RPM                    selinux-policy-2.4.6-30.el5
Selinux Enabled               True
Policy Type                   targeted
MLS Enabled                   True
Enforcing Mode                Permissive
Plugin Name                   plugins.allow_execmod
Host Name                     nagios
Platform                      Linux nagios 2.6.18-8.el5 #1 SMP Thu Mar 15
                              19:57:35 EDT 2007 i686 i686
Alert Count                   3
Line Numbers                  

Raw Audit Messages            

avc: denied { execmod } for comm="httpd" dev=sda3 egid=0 euid=0
exe="/usr/local/apache2/bin/httpd" exit=0 fsgid=0 fsuid=0 gid=0 items=0
name="libphp5.so" path="/usr/local/apache2/modules/libphp5.so" pid=31706
scontext=user_u:system_r:unconfined_t:s0 sgid=0
subj=user_u:system_r:unconfined_t:s0 suid=0 tclass=file
tcontext=system_u:object_r:lib_t:s0 tty=pts0 uid=0


注意红色字体:大体的意思是 您需要改变libphp5.so 的相应权限。
使用命令:
chcon -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so

我运气不好哈,加入后还是启不来:
httpd: Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: API module structure 'php5_module' in file /usr/local/apache2/modules/libphp5.so is garbled - expected signature 41503232 but saw 41503230 - perhaps this is not an Apache module DSO, or was compiled for a different Apache version?

二:大家看最后一行。
or was compiled for a different Apache version?
或编译不同的apache版本。

OK  换成 apache 2.0 一切搞定。


关于如上的方法,启不动,查看日志,再按日志里的命令操作,接着又会得到提示。继续操作。就可以完成安装。

net-snmp 在selinux开启的状态下也无法启动。需要用上面的方法来解决。或者直接关闭selinux 官网不推荐这么做。


一点小技巧。就到这吧。

更多selinux 相关知识点:
http://www.ibm.com/developerworks/cn/linux/l-selinux.html
IBM的我感觉写得挺好。




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-639945-1-1.html 上篇帖子: 菜鸟玩转Apache之配置使用篇 下篇帖子: apache常用的配置指令:ServerAdmin
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表