同一个盒子上有多个 PHP 版本
是否可以在同一个机器上运行多个版本的 PHP(例如 Rails)。这是我的问题,我需要开始开发一个新项目,并计划使用 PHP 5.3,以便我可以使用最新的 Zend 框架和活动记录。
但是,我需要托管应用程序的机器有 PHP 4.4,并且那里还托管着其他几个应用程序。我不想升级服务器上的 PHP 版本,因为过去我在升级 PHP 版本和弃用的功能时遇到了很多问题。
我想知道是否可以在同一个盒子上安装多个版本的 PHP,然后以某种方式指定您希望应用程序加载的版本(类似于 Rails)
Is it possible to have multiple versions of PHP running on the same box ( like rails ) . Here is my problem , I need to start development on a new project and was planning to use PHP 5.3 for it so that I can use the latest Zend framework and active record with it .
However the machine where I need to host my application has PHP 4.4 and there are several other applications hosted there . I do not want to upgrade the PHP version on the server as in the past I have faced a lot of issues while upgrading the PHP version and deprecated functions .
I was wondering if it is possible to have multiple version of PHP on the same box and then somehow specify the version that you want your application to load ( similar to rails )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是可能的。事实上,很多服务器都是这样运行的。您可能会不时看到 .php4 和 .php5 扩展名,指示应使用哪个版本来处理特定脚本。
ServerFault 解决了这个问题
同时运行 php4 和 php5
Yes, it is possible. In fact, many servers operate this way. You may see .php4 and .php5 extensions from time to time indicating which version that particular script should be handled with.
ServerFault addressed this question
Running php4 and php5 along side each other
您可以使用 Docker 在同一个机器上运行多个 PHP 版本。
示例命令如下:
此命令的作用如下:
/var/www
、/etc/apache2/sites-available
和/etc/ apache2/sites-enabled
复制到 Docker 容器对应的文件夹中。如果您的本地网站和/或 apache 配置位于不同的文件夹中,请替换-v
值的第一部分。即格式为:
<代码>
docker run -v /host/directory:/container/directory -other -options image_name command_to_run
(
如果运行此命令,则所有本地网站都应该可以通过端口 8055 访问 即通过 http://localsite:8055 等 URL 并由 PHP 5.5 处理,
请参阅 https://codeyourdream.com/blog/how-run-multiple-php-versions-apache-one-linux-machine-using-docker 了解更多详细信息。
附属说明:这是我团队的博客。
You can run multiple PHP versions on the same box using Docker.
An example command would be:
Here's what this command does:
/var/www
,/etc/apache2/sites-available
and/etc/apache2/sites-enabled
to the corresponding folders of Docker container. If your local websites and/or apache configs are located in different folders, replace the first part of-v
value.I.e. the format is:
docker run -v /host/directory:/container/directory -other -options image_name command_to_run
If you run this command, all your local websites should be available via port 8055 (i.e. via URLs like http://localsite:8055) and processed by PHP 5.5
See https://codeyourdream.com/blog/how-run-multiple-php-versions-apache-one-linux-machine-using-docker for more details.
Affiliation note: this is my team's blog.
一种可能性是使用 PHP 的一个版本作为 Apache 模块,而另一个版本作为 CGI ;但我更喜欢的一个想法是拥有:
这样,您就拥有完全不同的环境,彼此独立工作,并且您可以在每个环境中配置/修改您想要的任何内容,而不必冒破坏任何其他环境的风险。
(如果您不想在 URL 中包含端口号,我想您可以在不同的 Apache 实例前面放置一个代理,这样看起来就只有一个)
A possiblity is using one version of PHP as an Apache module, and the other version as a CGI ; but an idea I kind of like better is to have :
This way, you have totally different environments, that works independantly of each other, and you can configure/modify anything you want in each environment without risking breaking any of the others.
(And if you don't want to have port numbers in your URLs, I suppose you can put a proxy in front of your distinct Apache instances, so it seems there is only one)