php 我需要 libphp7.so 模块在 Centos 上配置 apache
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30126134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I need libphp7.so module to configure apache on Centos
提问by jmcordoba
I follow the tutorial of this linkto use php7 or phpng on my Centos 6.5 with apache.
我按照此链接的教程在我的 Centos 6.5 和 apache 上使用 php7 或 phpng。
I can execute php scripts in the console but I would like to be able to run php scripts using the Apache Server.
我可以在控制台中执行 php 脚本,但我希望能够使用 Apache 服务器运行 php 脚本。
I need some help because I can't find the libphp7.so module. I don't know if I have to build it or what.
我需要一些帮助,因为我找不到 libphp7.so 模块。我不知道我是否必须构建它或什么。
回答by Phillip Shipley
I believe you need to add --with-apxs2
to your configure script. According to the link you provided I do not see that in the configure flags. --with-apxs2
will "Build shared Apache 2.0 Handler module". You may also need to make sure in your apache configuration you have:
我相信您需要添加--with-apxs2
到配置脚本中。根据您提供的链接,我在配置标志中没有看到。--with-apxs2
将“构建共享的 Apache 2.0 处理程序模块”。您可能还需要确保在您的 apache 配置中有:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
The first time I built php7 it just displayed the source rather than execute it, but adding that caused it to execute the code.
我第一次构建 php7 时,它只是显示源代码而不是执行它,但是添加它会导致它执行代码。
If you want to try it out with Docker I just created a Docker image for PHP7 at https://registry.hub.docker.com/u/silintl/php7/You can also just view the Dockerfile which includes all the commands used to install and configure it.
如果您想使用 Docker 进行尝试,我刚刚在https://registry.hub.docker.com/u/silintl/php7/ 上为 PHP7 创建了一个 Docker 映像,您还可以查看 Dockerfile,其中包含用于安装和配置它。
回答by JanePage
Thanks Phillip who gaves some clues for this issue, but in my case I've solved my problem this way :
感谢 Phillip 为这个问题提供了一些线索,但就我而言,我已经通过这种方式解决了我的问题:
1 - Copy the Library php7.so that you have into apache module directory with this command : sudo cp /etc/httpd/modules/libphp7.so /opt/bitnami/apache2/modules
1 - 使用以下命令将库 php7.so 复制到 apache 模块目录中:sudo cp /etc/httpd/modules/libphp7.so /opt/bitnami/apache2/modules
2 - Add in your Apache config file following code :
2 - 在您的 Apache 配置文件中添加以下代码:
LoadModule php7_module ./modules/libphp7.so SetHandler application/x-httpd-php
LoadModule php7_module ./modules/libphp7.so SetHandler application/x-httpd-php
And PHP worked fine after that !
之后 PHP 运行良好!
回答by Isaiahiroko
In my config file /etc/httpd/conf.modules.d/15-php.conf
which is loaded by the parent config file /etc/httpd/conf/httpd.conf
I found the following default configuration:
在/etc/httpd/conf.modules.d/15-php.conf
由父配置文件加载的配置文件中,/etc/httpd/conf/httpd.conf
我找到了以下默认配置:
<IfModule !mod_php5.c>
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
</IfModule>
<IfModule !mod_php5.c>
<IfModule !prefork.c>
LoadModule php7_module modules/libphp7-zts.so
</IfModule>
</IfModule>
Using information provided by @JanePage and @PhilipShipley, i change it to this:
使用@JanePage 和@PhilipShipley 提供的信息,我将其更改为:
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
and Apache started working fine.
和 Apache 开始工作正常。