apache php selinux --Syntax error 无法加载模块

简介:
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
    [url]http://people.redhat.com/drepper/selinux-mem.html[/url] 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
    [url]http://bugzilla.redhat.com/bugzilla/enter_bug.cgi[/url] 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 官网不推荐这么做。


一点小技巧。就到这吧。



本文转自守住每一天51CTO博客,原文链接:http://blog.51cto.com/liuyu/78389,如需转载请自行联系原作者

相关文章
php常见问题,php.ini文件不存在或者找不到,mb_strlen()函数未定义系列问题,dll模块找不到的解决
本文介绍了解决PHP常见问题的步骤,包括定位和创建`php.ini`文件,以及解决`mb_strlen()`函数未定义和DLL模块加载错误的具体方法。
php常见问题,php.ini文件不存在或者找不到,mb_strlen()函数未定义系列问题,dll模块找不到的解决
|
消息中间件 前端开发 Kafka
【Azure 事件中心】使用Apache Flink 连接 Event Hubs 出错 Kafka error: No resolvable bootstrap urls
【Azure 事件中心】使用Apache Flink 连接 Event Hubs 出错 Kafka error: No resolvable bootstrap urls
379 2
|
Ubuntu PHP
Ubuntu下使用apt为Apache2编译PHP7.1
以上就是在Ubuntu系统下,使用apt为Apache2编译PHP7.1的过程。希望这个过程对你有所帮助,如果你在执行过程中遇到任何问题,都可以在网上找到相关的解决方案。
299 25
|
Ubuntu PHP Apache
在Ubuntu系统中为apt的apache2编译PHP 7.1的方法
以上就是在Ubuntu系统中为apt的apache2编译PHP 7.1的方法。希望这个指南能帮助你成功编译PHP 7.1,并在你的Apache服务器上运行PHP应用。
327 28
|
数据库连接 PHP Apache
PHP在Apache中如何运行?
PHP在Apache中如何运行?
536 5
|
关系型数据库 MySQL 应用服务中间件
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
这篇文章介绍了如何在Windows 7系统上搭建PHP、MySQL和Apache环境,并部署ECShop项目,包括安装配置步骤、解决常见问题以及使用XAMPP集成环境的替代方案。
294 1
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
|
测试技术 PHP 开发工具
php性能监测模块XHProf安装与测试
【10月更文挑战第13天】php性能监测模块XHProf安装与测试
240 0
|
IDE PHP 开发工具
PHP 安装配置Xdebug模块详解
【7月更文挑战第22天】
342 3
|
存储 安全 PHP
安全开发-PHP应用&文件管理模块&显示上传&黑白名单类型过滤&访问控制&文件管理模块&包含&上传&遍历&写入&删除&下载&安全
安全开发-PHP应用&文件管理模块&显示上传&黑白名单类型过滤&访问控制&文件管理模块&包含&上传&遍历&写入&删除&下载&安全
271 1
|
运维 JavaScript Serverless
Serverless 应用引擎产品使用合集之php工程已经部署,可以正常访问数据库,静态资源样式无法正常加载,要怎么配置
阿里云Serverless 应用引擎(SAE)提供了完整的微服务应用生命周期管理能力,包括应用部署、服务治理、开发运维、资源管理等功能,并通过扩展功能支持多环境管理、API Gateway、事件驱动等高级应用场景,帮助企业快速构建、部署、运维和扩展微服务架构,实现Serverless化的应用部署与运维模式。以下是对SAE产品使用合集的概述,包括应用管理、服务治理、开发运维、资源管理等方面。
Serverless 应用引擎产品使用合集之php工程已经部署,可以正常访问数据库,静态资源样式无法正常加载,要怎么配置

热门文章

最新文章

推荐镜像

更多