简体   繁体   English

无法打开 apache 中的 php 文件 2.4 Centos 6

[英]Can't open php file in apache 2.4 Centos 6

I have a server that run Centos 6. Recently I upgrade the php to 7.2 using remi repo and apache 2.4 using the sclo(httpd24).我有一台运行 Centos 6 的服务器。最近我使用 remi repo 将 php 升级到 7.2,使用 sclo(httpd24) 将 apache 升级到 2.4。

[user@server1 ~]$ httpd -v
Server version: Apache/2.4.34 (Red Hat)
Server built:   May 28 2020 08:47:33

[user@server1 ~]$ php -v
PHP 7.2.33 (cli) (built: Aug  4 2020 10:02:54) ( NTS )

My issue is if i put an phpinfo() in /var/www/html, my browser didn't show anything, and if i open the source i only see the php code.我的问题是,如果我将 phpinfo() 放入 /var/www/html,我的浏览器不会显示任何内容,如果我打开源代码,我只会看到 php 代码。

How do i connect the apache and php together?如何将 apache 和 php 连接在一起? Thanks..谢谢..

Have you made sure that inside the apache server configuration httpd.conf file you are correctly pointing to the php.so file??您是否确定在 apache 服务器配置httpd.conf文件中您正确指向 php.so 文件?

You need to make sure the LoadModule php7_module /path/to/the/php@7.2/version/libphp7.so line is in your configuration.您需要确保LoadModule php7_module /path/to/the/php@7.2/version/libphp7.so行在您的配置中。 If you recently changed the PHP to 7.2 you need to modify the line so it points to the correct php version.如果您最近将 PHP 更改为 7.2,则需要修改该行以使其指向正确的 php 版本。

In my case I use the php 7.2, 7.3 and 7.4 versions for different purposes and inside my httpd.conf file i have the following lines:在我的例子中,我将 php 7.2、7.3 和 7.4 版本用于不同的目的,在我的 httpd.conf 文件中,我有以下几行:

#LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
#LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so

As you can see each version point to a different so file, you need to find the correct one for the 7.2 version and point to it by commenting or uncommenting them depending on the php version.正如您所看到的,每个版本都指向不同的 so 文件,您需要为 7.2 版本找到正确的文件,并根据 php 版本通过注释或取消注释来指向它。

I upgrade the php to 7.2 using remi我使用 remi 将 php 升级到 7.2

Package in my repository are build against base httpd version 2.2.我存储库中的 Package 是针对基础 httpd 版本 2.2 构建的。

You still can use httpd 2.4 (from SCL), but in this case you need to use FPM您仍然可以使用 httpd 2.4(来自 SCL),但在这种情况下您需要使用 FPM

Read: PHP Configuration Tips阅读: PHP 配置技巧

BTW, as CentOS 6 is close to its end of life (in a few months), I heartily recommend you use a more recent version of CentOS (7 or 8 both have httpd 2.4 by default)顺便说一句,由于 CentOS 6 的生命周期即将结束(几个月后),我衷心建议您使用更新版本的 CentOS(默认情况下 7 或 8 都具有 httpd 2.4)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM