Apache不能解析php,和配置文件无关

本文记录了一次解决mod_php模块在CentOS系统上安装问题的过程。作者先回顾了安装顺序,发现是在安装nginx和php之后,再安装apache时出现问题。通过卸载并重新安装mod_php模块,最终成功使Apache能够解析PHP文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

做个记录


[root@vm-centos conf.d]# rpm -ql mod_php72w
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/10-php.conf
/usr/lib64/httpd/modules/libphp7-zts.so
/usr/lib64/httpd/modules/libphp7.so
/usr/share/httpd/icons/php.gif
/var/lib/php/session
/var/lib/php/wsdlcache
[root@vm-centos conf.d]# 
[root@vm-centos conf.d]# ls -l /usr/lib64/httpd/modules/*php*
ls: cannot access /usr/lib64/httpd/modules/*php*: No such file or directory
[root@vm-centos conf.d]# 
[root@vm-centos conf.d]# ls -l /etc/httpd/modules/*php*
ls: cannot access /etc/httpd/modules/*php*: No such file or directory

看起来mod_php安装的有问题,回想一下,我是先安装的nginx+php,在装php的时候把mod_php也同时安装了,后面才安装的apache。


卸载mod_php重新安装

[root@vm-centos conf.d]# yum remove mod_php
[root@vm-centos conf.d]# yum install mod_php

再次检查mod_php

[root@vm-centos conf.d]# ls -l /etc/httpd/modules/*php*
-rwxr-xr-x. 1 root root 5124456 Oct 12 03:27 /etc/httpd/modules/libphp7.so
-rwxr-xr-x. 1 root root 5313960 Oct 12 03:27 /etc/httpd/modules/libphp7-zts.so
[root@vm-centos conf.d]# 

测试apache已经可以解析php文件了。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值