在 XAMPP for Windows 中升级 PHP?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2154762/
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
Upgrading PHP in XAMPP for Windows?
提问by Stanley Ngumo
I would like to know how you upgrade PHP in Xampp for Windows? I tried to download the latest PHP version from the main PHP site but when I check (phpinfo) I still get that the previous version is still in use.
我想知道您如何在 Xampp for Windows 中升级 PHP?我试图从主要的 PHP 站点下载最新的 PHP 版本,但是当我检查 (phpinfo) 时,我仍然发现以前的版本仍在使用中。
采纳答案by s-sharma
Take a backup of your htdocs and data folder (subfolder of MySQL folder), reinstall upgraded version and replace those folders.
备份您的 htdocs 和数据文件夹(MySQL 文件夹的子文件夹),重新安装升级版本并替换这些文件夹。
Note:In case you have changed config files like PHP (php.ini), Apache (httpd.conf)or any other, please take back up of those files as well and replace them with newly installed version.
注意:如果您更改了PHP (php.ini)、Apache (httpd.conf)或任何其他配置文件,请同时备份这些文件并将其替换为新安装的版本。
回答by Dharmang
You can go through the following link as it helped me, should work for you as well. http://hype-free.blogspot.com/2007/07/updating-php-in-xampp-for-windows.html
您可以访问以下链接,因为它对我有帮助,也应该对您有用。http://hype-free.blogspot.com/2007/07/updating-php-in-xampp-for-windows.html
Realizing that my answer helped couple of users, here is the edit from original link:
意识到我的回答帮助了几个用户,这是原始链接的编辑:
Edit:
编辑:
First of all Always backup your data.
首先,始终备份您的数据。
- Download the latest binary version of PHP (make sure to get the .zip package not the installer)
- De-archive it to a directory
- Overwrite the contents of directory in the php subfolder of your XAMPP installation directory.
- Overwrite the contents of the directory apache\bin with the newer versions.
- Now the trick: take the files which have a '_2' in their names (for example php5apache2_2.dll or php5apache2_2_filter.dll), copy them in the apache\bin subdirectory and remove the '_2' part, overwriting the existing files. This is necessary because by XAMPP uses Apache version 2.2 and the files with the 2 prefix are built for Apache 2.0, so you must take the files build for the newer version (which has a different plugin interface) and rename them in the filenames XAMPP expects.
- 下载最新的 PHP 二进制版本(确保获取 .zip 包而不是安装程序)
- 将其解压缩到一个目录
- 覆盖 XAMPP 安装目录的 php 子文件夹中目录的内容。
- 用较新的版本覆盖目录 apache\bin 的内容。
- 现在的诀窍是:将名称中包含“_2”的文件(例如 php5apache2_2.dll 或 php5apache2_2_filter.dll)复制到 apache\bin 子目录中并删除“_2”部分,覆盖现有文件。这是必要的,因为 XAMPP 使用 Apache 2.2 版,并且带有 2 前缀的文件是为 Apache 2.0 构建的,因此您必须为较新版本(具有不同的插件接口)构建文件,并在 XAMPP 期望的文件名中重命名它们.
NOTE: there are two directories to be updated with new version of files, namely phpsub-directory and apache/binsub-directory, inside XAMPP installation.
注意:XAMPP 安装中有两个目录需要更新新版本的文件,即php子目录和apache/bin子目录。
回答by Vikas Khunteta
Simplest method to upgrade PHPin XAMPP:
最简单的方法来升级PHP中XAMPP:
- Download latest portable version of
XAMPP. - Extract the archive(not where
XAMPPalready installed). - Copy the
PHPfolder from the extracted archive. - Keep back up of
PHPfolder which is in installedXAMPPdirectory. You can backup it like changing thePHPfolder name toPHP-oldor likePHP-version-number - Paste the
PHPfolder which you copied from the extracted archive. - Replace the
php.inifile with your backup folderphp.inifile in case you have changed the default settings earlier. - That's all, start/restart the
server.
- 下载最新的便携式版本
XAMPP。 - 提取存档(不是
XAMPP已经安装的地方)。 PHP从解压缩的存档中复制文件夹。- 备份
PHP安装XAMPP目录中的文件夹。您可以备份它,例如将PHP文件夹名称更改为PHP-old或喜欢PHP-version-number - 粘贴
PHP您从提取的存档中复制的文件夹。 - 如果您之前更改了默认设置
php.ini,请将该文件替换为您的备份文件夹php.ini文件。 - 就是这样,启动/重新启动
server.
回答by CRK
I needed to update my php from 5.3.8 to 5.3.29. (both Thread Safe) on Windows
我需要将我的 php 从5.3.8更新到 5.3.29。(都是线程安全的)在Windows 上
Steps I did:
我做的步骤:
- Back-up my initial php folder, under xampp.
- Downloaded zip from here http://windows.php.net/download/#php-5.3-ts-VC9-x86
- Unpack that zip into xampp folder.
- Copied php.ini file from old php folder into new one.
- Copied a couple of folders that I didn't have in the new php folder, from old one. For example: extras, which contained browscap.ini file (this one is needed)
- Copied needed extensions, from old php extfolder into new php extfolder. I copied them manually, by checking list of extensions from php.ini file.
- Copied also these files: php5apache2_2.dll, php5ts.dll
- 备份我的初始 php 文件夹,在 xampp 下。
- 从这里下载 zip http://windows.php.net/download/#php-5.3-ts-VC9-x86
- 将该 zip 解压缩到 xampp 文件夹中。
- 将旧 php 文件夹中的 php.ini 文件复制到新文件夹中。
- 从旧文件夹复制了几个我在新 php 文件夹中没有的文件夹。例如: extras,其中包含 browscap.ini 文件(需要这个)
- 将所需的扩展名从旧的 php ext文件夹复制到新的 php ext文件夹中。我通过检查 php.ini 文件中的扩展名列表手动复制了它们。
- 还复制了这些文件:php5apache2_2.dll、php5ts.dll
Hope that I covered everything.
希望我涵盖了所有内容。
Most probably these steps will not work if you change major versions of php, e.g. 5.3.x to 5.4.x, but for minor versions, it should work.
如果您更改 php 的主要版本,例如 5.3.x 到 5.4.x,这些步骤很可能不起作用,但对于次要版本,它应该可以工作。
Also, a good way to see what's wrong... start command line and try to start httpd.exe, under xampp/apache/bin from there, it will list errors found.
另外,一个很好的方法来查看有什么问题...启动命令行并尝试在 xampp/apache/bin 下启动 httpd.exe,它会列出发现的错误。
回答by Anurag Prashant
I have upgraded to php7.2from php5.6
我已经升级到php7.2从php5.6
Steps which I followed.
我遵循的步骤。
- Download PHP binary from here. I have downloaded VC15 x86 Thread Safe Zipfile.
- Created a backup of xampp/phpfolder.
- Extract all the contents of zip file to xampp/php folder.
- Copied php.ini (as I have modified it before and I want my configuration back, if you were using default one then skip this step.)
- Edit below file
- 从这里下载 PHP 二进制文件。我已经下载了VC15 x86 线程安全 Zip文件。
- 创建了xampp/php文件夹的备份。
- 将 zip 文件的所有内容解压到 xampp/php 文件夹。
- 复制php.ini(因为我之前修改过它,我想要我的配置,如果您使用默认配置,请跳过此步骤。)
- 编辑下面的文件
C:\xampp\apache\conf\extra\http-xampp.conf
C:\xampp\apache\conf\extra\http-xampp.conf
5.1. Replace
5.1. 代替
LoadFile "C:/xampp/php/php5ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
加载文件“C:/xampp/php/php5ts.dll”
加载文件“C:/xampp/php/libpq.dll”
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
to
到
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
加载文件“C:/xampp/php/php7ts.dll”
加载文件“C:/xampp/php/libpq.dll”
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
- Restart Apache
- 重启阿帕奇
回答by tanzeem
download your desired version of php binary from http://windows.php.net/download/website. download Thread Safe binary zip version. Unzip the downloaded version of the PHP in a separate folder. Please make sure that your new php folder name is not "PHP". May be you can use filder name as the version name. For example for php 5.4 you can use php54.
从http://windows.php.net/download/网站下载所需版本的 php 二进制文件。下载线程安全二进制 zip 版本。将下载的 PHP 版本解压到单独的文件夹中。请确保您的新 php 文件夹名称不是“PHP”。可能您可以使用文件名作为版本名称。例如,对于 php 5.4,您可以使用 php54。
Copy the new php folder into your xampp folder. Now go to yourxampp/apache/conf/extra folder. Open file httpd-xampp.conf from the folder extra. Change the following variables:
将新的 php 文件夹复制到您的 xampp 文件夹中。现在转到 yourxampp/apache/conf/extra 文件夹。从额外文件夹中打开文件 httpd-xampp.conf。更改以下变量:
Variable PHPINIDir to be / Varaible LoadModule to be //php5apache2_2.dl
变量 PHPINIDir 为 / 变量 LoadModule 为 //php5apache2_2.dl
Save the file httpd-xampp.conf. Restart your XAMPP apache server. If your server get restarted successfully then your server php version is upgraded.
保存文件 httpd-xampp.conf。重新启动您的 XAMPP apache 服务器。如果您的服务器成功重新启动,则您的服务器 php 版本已升级。
回答by prodigitalson
I think you need to actually download and install XAMPP with the desired PHP version. I dont think you can just upgrade the components of XAMPP individually unless there is a facility provided for this within XAMPP itself.
我认为您需要实际下载并安装具有所需 PHP 版本的 XAMPP。我不认为您可以单独升级 XAMPP 的组件,除非 XAMPP 本身提供了为此提供的工具。
回答by IT-Pro
I don't have enough reputation to comment yet, but, to add to ssharma's answer:
我还没有足够的声誉来发表评论,但是,要添加到 ssharma 的答案中:
After you copy your htdocs folder to a safe place, just export your databases from PHPmyadmin. Simply go to each of your databases and click on the export tab at the top. Export them as sql (or whatever, really - just remember what you chose). Upgrade your XAMPP installation. Now, in the new version of XAMPP, create the databases that you want to re-insert. Example: you have a database named 'test' that you exported from your old installation, name the new, empty database the same thing. Now, go into 'test' and hit the import button along the top (right next to the export button). Click on choose file, find the sql file that you exported earlier (should be 'test.sql') and import. Your tables and data will be in place.
将 htdocs 文件夹复制到安全位置后,只需从 PHPmyadmin 导出数据库。只需转到您的每个数据库,然后单击顶部的导出选项卡。将它们导出为 sql(或其他任何东西,真的——记住你选择了什么)。升级您的 XAMPP 安装。现在,在新版本的 XAMPP 中,创建要重新插入的数据库。示例:您有一个从旧安装导出的名为“test”的数据库,将新的空数据库命名为相同的名称。现在,进入“测试”并点击顶部的导入按钮(在导出按钮旁边)。点击选择文件,找到你之前导出的sql文件(应该是'test.sql')并导入。您的表格和数据将就位。
NOTE: There's an option to export the entire collection of databases (it names the file 127.0.0.1.sql). But, I've never had much luck getting it to import correctly. Do each of your databases separately to ensure it works. I made this post kind of long-winded, but that's because I like to write for the people that don't know exactly what they're doing yet (I, myself, was there not too long ago (all of us were at some point)).
注意:有一个选项可以导出整个数据库集合(它将文件命名为 127.0.0.1.sql)。但是,我从来没有很幸运地正确导入它。分别执行每个数据库以确保其正常工作。我写这篇文章有点啰嗦,但那是因为我喜欢为那些还不知道他们在做什么的人写作(我,我自己,不久前在那里(我们所有人都在某个时候)观点))。
Shorthand version of my answer:
1) Export your databases individually
2) Import into your new installation of XAMPP
我的答案的简写版本:
1) 单独导出数据库
2) 导入到新安装的 XAMPP
回答by Andrés
There are newer beta versions of Xampp that come with newer PHP upgrades.
有更新的 Xampp 测试版随更新的 PHP 升级而来。
you should check at http://www.apachefriends.org
回答by Muhammad Younus
- Go to
phpinfo(), press ctrl+f, and typethreadto check the value. - If it is enabled download the non thread safe version, otherwise download the thread safe version from here(zip).
- Extract it, and rename the folder to
php. - Go to your xampp folder rename the default
phpfolder to something else. - Copy the extracted (renamed
php) folder in xampp directory. - Copy the
php.inifile from default/oldphpfolder (That you renamed) and paste it into the newphpfolder. - Restart xampp server and you're good to go.
- 转到
phpinfo(),按ctrl+ f,然后键入thread以检查值。 - 如果启用,请下载非线程安全版本,否则从此处(zip)下载线程安全版本。
- 提取它,并将文件夹重命名为
php. - 转到您的 xampp 文件夹,将默认
php文件夹重命名为其他名称。 - 将提取(重命名
php)的文件夹复制到 xampp 目录中。 php.ini从默认/旧php文件夹(您重命名的文件夹)复制文件并将其粘贴到新php文件夹中。- 重新启动 xampp 服务器,您就可以开始了。

