如何将 php 从 5.5 降级到 5.3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25397219/
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
How to downgrade php from 5.5 to 5.3
提问by user1985916
Is there a way to downgrade php 5.5 to 5.3 in xampp? I searched on google but every one just tell me to uninstall xampp and install an older version. Could I have php 5.5 downgrade to 5.3 without reinstall xampp?
有没有办法在 xampp 中将 php 5.5 降级到 5.3?我在谷歌上搜索过,但每个人都告诉我卸载 xampp 并安装旧版本。我可以在不重新安装 xampp 的情况下将 php 5.5 降级到 5.3 吗?
回答by James
Short answer is no.
简短的回答是否定的。
XAMPP is normally built around a specific PHP version to ensure plugins and modules are all compatible and working correctly.
XAMPP 通常围绕特定的 PHP 版本构建,以确保插件和模块都兼容并正常工作。
If your project specifically needs PHP 5.3 - the cleanest method is simply reinstalling an older version of XAMPP with PHP 5.3 packaged into it.
如果您的项目特别需要 PHP 5.3 - 最干净的方法是简单地重新安装旧版本的 XAMPP,并将 PHP 5.3 打包到其中。
XAMPP 1.7.7was their last update before moving off PHP 5.3.
XAMPP 1.7.7是他们离开 PHP 5.3 之前的最后一次更新。
回答by Pavlo Zhukov
Long answer: it is possible!
长答案:有可能!
- Temporarily rename existing xampp folder
- Install xampp 1.7.7 into xampp folder name
- Folder containing just installed 1.7.7 distribution rename to different name and previously existing xampp folder rename back just to xampp.
- In xampp folder rename phpand apachefolders to different names (I propose php_prev and apache_prev) so you can after switch back to them by renaming them back.
- Copy apache and php folders from folder with xampp 1.7.7 into xampp directory
In xampp directory comment line apache/conf/httpd.conf:458
#Include "conf/extra/httpd-perl.conf"
In xampp directory do next replaces in files:
- 临时重命名现有的 xampp 文件夹
- 将 xampp 1.7.7 安装到 xampp 文件夹名称中
- 包含刚刚安装的 1.7.7 发行版的文件夹重命名为不同的名称,之前存在的 xampp 文件夹重命名回 xampp。
- 在 xampp 文件夹中,将php和apache文件夹重命名为不同的名称(我建议使用 php_prev 和 apache_prev),这样您就可以通过重命名它们来切换回它们。
- 将 apache 和 php 文件夹从 xampp 1.7.7 文件夹复制到 xampp 目录中
在 xampp 目录注释行 apache/conf/httpd.conf:458
#Include "conf/extra/httpd-perl.conf"
在 xampp 目录中执行 next 替换文件:
php/pci.bat:15
php/pci.bat:15
from
从
"C:\xampp\php\.\php.exe" -f "\xampp\php\pci" -- %*
"C:\xampp\php\.\php.exe" -f "\xampp\php\pci" -- %*
to
到
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\php.exe" -f "%XAMPPPHPDIR%\pci" -- %*
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\php.exe" -f "%XAMPPPHPDIR%\pci" -- %*
php/pciconf.bat:15
php/pciconf.bat:15
from
从
"C:\xampp\php\.\php.exe" -f "\xampp\php\pciconf" -- %*
"C:\xampp\php\.\php.exe" -f "\xampp\php\pciconf" -- %*
to
到
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\.\php.exe" -f "%XAMPPPHPDIR%\pciconf" -- %*
set XAMPPPHPDIR=C:\xampp\php
"%XAMPPPHPDIR%\.\php.exe" -f "%XAMPPPHPDIR%\pciconf" -- %*
php/pear.bat:33
php/pear.bat:33
from
从
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
到
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/peardev.bat:33
php/peardev.bat:33
from
从
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
到
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/pecl.bat:32
php/pecl.bat:32
from
从
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\.\php.exe"
to
到
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php\"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:\xampp\php\"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:\xampp\php\php.exe"
php/phar.phar.bat:1
php/phar.phar.bat:1
from
从
%~dp0php.exe %~dp0pharcommand.phar %*
%~dp0php.exe %~dp0pharcommand.phar %*
to
到
"%~dp0php.exe" "%~dp0pharcommand.phar" %*
"%~dp0php.exe" "%~dp0pharcommand.phar" %*
Enjoy new XAMPP with PHP 5.3
使用 PHP 5.3 享受新的 XAMPP
Checked by myself in XAMPP 5.6.31, 7.0.15 & 7.1.1 with XAMPP Control Panel v3.2.2
我自己在 XAMPP 5.6.31、7.0.15 和 7.1.1 中使用 XAMPP 控制面板 v3.2.2 进行了检查
回答by Snow Bases
It is possible! Yes
有可能的!是的
In many cases, you might want to use XAMPP with a different PHP version than the one that comes preinstalled. You might do this to get the benefits of a newer version of PHP, or to reproduce bugs using an earlier version of PHP.
在许多情况下,您可能希望使用与预装版本不同的 PHP 版本的 XAMPP。您可能会这样做以获得较新版本 PHP 的好处,或者使用较早版本的 PHP 重现错误。
To use a different version of PHP with XAMPP, follow these steps:
要在 XAMPP 中使用不同版本的 PHP,请按照下列步骤操作:
Download a binary buildof the PHP version that you wish to use from the PHP website, and extract the contents of the compressed archive file to your XAMPP installation directory (usually, C:\xampp). Ensure that you give it a different directory name to avoid overwriting the existing PHP version. For example, in this tutorial, we'll call the new directory
C:\xampp\php5-6-0
. NOTE: Ensure that the PHP build you download matches the Apache build (VC9 or VC11) in your XAMPP platform.Within the new directory, rename the php.ini-development file to php.ini. If you prefer to use production settings, you could instead rename the php.ini-production file to php.ini.
Edit the httpd-xampp.conf file in the apache\conf\extra\ subdirectory of your XAMPP installation directory. Within this file, search for all instances of the old PHP directory path and replace them with the path to the new PHP directory created in Step 1. In particular, be sure to change the lines
从 PHP 网站下载您希望使用的 PHP 版本的二进制版本,并将压缩存档文件的内容解压缩到您的 XAMPP 安装目录(通常为 C:\xampp)。确保为其指定不同的目录名称以避免覆盖现有的 PHP 版本。例如,在本教程中,我们将调用新目录
C:\xampp\php5-6-0
。注意:确保您下载的 PHP 版本与 XAMPP 平台中的 Apache 版本(VC9 或 VC11)相匹配。在新目录中,将 php.ini-development 文件重命名为 php.ini。如果您更喜欢使用生产设置,则可以将 php.ini-production 文件重命名为 php.ini。
编辑 XAMPP 安装目录的 apache\conf\extra\ 子目录中的 httpd-xampp.conf 文件。在此文件中,搜索旧 PHP 目录路径的所有实例,并将它们替换为在步骤 1 中创建的新 PHP 目录的路径。特别是,请务必更改行
LoadFile "/xampp/php/php5ts.dll"
LoadFile "/xampp/php/libpq.dll"
LoadModule php5_module "/xampp/php/php5apache2_4.dll"
to
到
LoadFile "/xampp/php5-6-0/php5ts.dll"
LoadFile "/xampp/php5-6-0/libpq.dll"
LoadModule php5_module "/xampp/php5-6-0/php5apache2_4.dll"
NOTE: Remember to adjust the file and directory paths above to reflect valid paths on your system.
- Restart your Apache server through the XAMPP control panel for your changes to take effect. The new version of PHP should now be active. To verify this, browse to the URL
http://localhost/xampp/phpinfo.php
, which displays the output of the phpinfo() command, and check the version number at the top of the page.
注意:记住调整上面的文件和目录路径以反映系统上的有效路径。
- 通过 XAMPP 控制面板重新启动 Apache 服务器以使您的更改生效。新版本的 PHP 现在应该处于活动状态。要验证这一点,请浏览到
http://localhost/xampp/phpinfo.php
显示 phpinfo() 命令输出的 URL ,并检查页面顶部的版本号。
回答by Marcin Wieczorek
I did this in my local environment. Wasn't difficult but obviously it was done in "unsupported" way.
我在本地环境中这样做了。并不难,但显然它是以“不受支持”的方式完成的。
To do the downgrade you need just to download php 5.3 from http://php.net/releases/(zip archive), than go to xampp folder and copy subfolder "php" to e.g. php5.5 (just for backup). Than remove content of the folder php and unzip content of zip archive downloaded from php.net. The next step is to adjust configuration (php.ini) - you can refer to your backed-up version from php 5.5. After that just run xampp control utility - everything should work (at least worked in my local environment). I didn't found any problem with such installation, although I didn't tested this too intensively.
要进行降级,您只需要从http://php.net/releases/(zip存档)下载 php 5.3 ,然后转到 xampp 文件夹并将子文件夹“php”复制到例如 php5.5(仅用于备份)。然后删除文件夹 php 的内容并解压缩从 php.net 下载的 zip 存档的内容。下一步是调整配置(php.ini)——你可以从 php 5.5 中参考你的备份版本。之后只需运行 xampp 控制实用程序 - 一切都应该正常工作(至少在我的本地环境中工作)。我没有发现这种安装有任何问题,尽管我没有对此进行过多的测试。