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,如需转载请自行联系原作者

相关文章
|
8月前
|
Ubuntu PHP
Ubuntu下使用apt为Apache2编译PHP7.1
以上就是在Ubuntu系统下,使用apt为Apache2编译PHP7.1的过程。希望这个过程对你有所帮助,如果你在执行过程中遇到任何问题,都可以在网上找到相关的解决方案。
157 25
|
8月前
|
Ubuntu PHP Apache
在Ubuntu系统中为apt的apache2编译PHP 7.1的方法
以上就是在Ubuntu系统中为apt的apache2编译PHP 7.1的方法。希望这个指南能帮助你成功编译PHP 7.1,并在你的Apache服务器上运行PHP应用。
193 28
|
8月前
|
关系型数据库 MySQL Linux
查看Linux、Apache、MySQL、PHP版本的技巧
以上就是查看Linux、Apache、MySQL、PHP版本信息的方法。希望这些信息能帮助你更好地理解和使用你的LAMP技术栈。
392 17
|
消息中间件 前端开发 Kafka
【Azure 事件中心】使用Apache Flink 连接 Event Hubs 出错 Kafka error: No resolvable bootstrap urls
【Azure 事件中心】使用Apache Flink 连接 Event Hubs 出错 Kafka error: No resolvable bootstrap urls
239 2
|
数据库连接 PHP Apache
PHP在Apache中如何运行?
PHP在Apache中如何运行?
431 5
|
关系型数据库 MySQL 应用服务中间件
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
这篇文章介绍了如何在Windows 7系统上搭建PHP、MySQL和Apache环境,并部署ECShop项目,包括安装配置步骤、解决常见问题以及使用XAMPP集成环境的替代方案。
193 1
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
|
PHP Windows
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
261 1
|
关系型数据库 Linux 网络安全
"Linux系统实战:从零开始部署Apache+PHP Web项目,轻松搭建您的在线应用"
【8月更文挑战第9天】Linux作为服务器操作系统,凭借其稳定性和安全性成为部署Web项目的优选平台。本文以Apache Web服务器和PHP项目为例,介绍部署流程。首先,通过包管理器安装Apache与PHP;接着创建项目目录,并上传项目文件至该目录;根据需要配置Apache虚拟主机;最后重启Apache服务并测试项目。确保防火墙允许HTTP流量,正确配置数据库连接,并定期更新系统以维持安全。随着项目复杂度提升,进一步学习高级配置将变得必要。
1004 0
|
运维 JavaScript Serverless
Serverless 应用引擎产品使用合集之php工程已经部署,可以正常访问数据库,静态资源样式无法正常加载,要怎么配置
阿里云Serverless 应用引擎(SAE)提供了完整的微服务应用生命周期管理能力,包括应用部署、服务治理、开发运维、资源管理等功能,并通过扩展功能支持多环境管理、API Gateway、事件驱动等高级应用场景,帮助企业快速构建、部署、运维和扩展微服务架构,实现Serverless化的应用部署与运维模式。以下是对SAE产品使用合集的概述,包括应用管理、服务治理、开发运维、资源管理等方面。
Serverless 应用引擎产品使用合集之php工程已经部署,可以正常访问数据库,静态资源样式无法正常加载,要怎么配置
|
Oracle 关系型数据库 Shell
实时计算 Flink版操作报错合集之遇到报错:Error: Could not find or load main class org.apache.flink.cdc.cli.CliFrontend,是什么导致的
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
475 0

推荐镜像

更多