如何从htaccess为多个PHP版本配置Apache

编程入门 行业动态 更新时间:2024-10-24 10:24:08
本文介绍了如何从htaccess为多个PHP版本配置Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经安装了Remi存储库中的PHP版本集合,该问题本身可能会被忽略,但是为了理解我尝试过的处理过程而保留了该版本.

I have installed a collection of PHP versions from Remi Repositories, which may be ignored, for the question itself, but kept for the sake of understanding the processed I tried.

它们可以从命令行正常运行,但是我想将它们与Apache 2(Fedora 24上的httpd)一起使用,并运行多个虚拟主机,如下所示:

They work fine from command line, but I'd like to use them with Apache 2 (httpd on Fedora 24), running multiple virtual hosts as in:

php54.test php55.test php56.test php70.test php71.test

我已经创建了VirtualHost conf文件,并且每个文件都工作正常.

I have created the VirtualHost conf files and each one is working fine.

我想运行每个对应的php版本(根据建议的ServerName),但是我找不到如何从每个虚拟主机加载PHP的方法. 我找不到相应的Remi libphpX.so来将它们作为模块加载:

I want to run each corresponding php version (accordingly to the suggestive ServerName), but I can't find how to load PHP from each Virtual Host. I couldn't find the corresponding Remi libphpX.so for loading them as modules:

<VirtualHost *:80> ServerName php54.test DocumentRoot /var/www/php54 #SOMETHING LIKE THIS... LoadModule php??_module modules/libphp??.so </VirtualHost>

我有一个共享托管,这不是新闻,它使我可以从.htaccess更改PHP版本,并且我可以执行以下操作:

I have, and this is not news, a shared hosting that allows me to change PHP version from .htaccess and I can do something like this:

AddHandler application/x-httpd-php54 .php AddHandler application/x-httpd-php55 .php AddHandler application/x-httpd-php56 .php AddHandler application/x-httpd-php7 .php AddHandler application/x-httpd-php71 .php

我现在看起来像是一个虚拟人,但是如何使用相同的.htaccess切换来提供多个PHP版本呢?

I may look like a dummy now, but how can I do the same .htaccess switching for having multiple PHP versions available?

我可能不知道在Google上搜索什么以及如何找到最匹配的答案.

I probably am not knowing what and how to search on Google to find the best matched answer.

推荐答案

您不能使用mod_php的多个版本.

You cannot use multiple versions of mod_php.

更好的解决方案是使用php-fpm(Fastcgi进程管理器),在每个虚拟主机中使用一个SetHandler到fcgi服务器:

Better solution is to use php-fpm (the Fastcgi Process Manager), using in each vhost a SetHandler to fcgi server:

SetHandler "proxy:fcgi://127.0.0.1:9070"

或(使用Unix域套接字)

Or (using unix domain socket)

SetHandler "proxy:unix:/var/opt/remi/php70/run/php-fpm/www.sock|fcgi://localhost"

本文对此进行了说明:我的PHP工作站.

This is described in this article : My PHP workstation.

更多推荐

如何从htaccess为多个PHP版本配置Apache

本文发布于:2023-11-01 01:19:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   版本   htaccess   Apache   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!