在 Windows 版 XAMPP 中升级 PHP?
我想知道如何在 Xampp for Windows 中升级 PHP?我尝试从 PHP 主站点下载最新的 PHP 版本,但当我检查 (phpinfo) 时,我仍然发现以前的版本仍在使用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(19)
Xampp 有较新的 Beta 版本,附带有较新的 PHP 升级。
你应该检查 http://www.apachefriends.org
There are newer beta versions of Xampp that come with newer PHP upgrades.
you should check at http://www.apachefriends.org
我已通过从此处下载文件将 PHP 更新到 8。
https://sourceforge.net/projects/xampp/files/XAMPP %20Windows/8.0.6/
通过将之前的 PHP 文件夹重命名为其他名称,将其上传到 xampp 目录。但是,在启动 apache 时出现以下错误。
之后,我也用我下载的新版本替换了 xampp 文件夹中的 apache 目录,它解决了问题。
尝试访问 phpmyadmin 页面时遇到另一个问题,然后再次从 xampp 目录中重命名以前的 phpmyadmin 文件夹,并从下载的文件上传新版本。它解决了这个问题。
I've updated the PHP to 8 by downloading the files from here.
https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/8.0.6/
Uploaded it to the xampp directory by renaming the previous PHP folder to something else. But, then got the following error while starting the apache.
After that, I've replaced the apache directory as well from the xampp folder with a newer version which I've downloaded, it sorted the issue out.
Got another problem while trying to access the phpmyadmin page, then again renamed the previous phpmyadmin folder from the xampp directory and uploaded the new version from the downloaded files. It's fixed the issue.
http://www.apachefriends.org/en/xampp-windows.html
在此站点中您可以获得
XAMPP 附加组件,
通过使用此附加组件您可以升级到最新版本。
http://www.apachefriends.org/en/xampp-windows.html
In this site you can get
XAMPP Add-Ons
by using this add on you can upgrade the latest versions.
我刚刚将旧的 PHP 5.3.X 便携式 XAMPP(包括 Mercury 和 FileZilla 和 Tomcat)升级到 PHP 5.6.X 便携式 XAMPP(包括以前的版本)...
我的方法:
max_upload_size
等.ini 以及/apache/conf/extra/httpd-xampp.conf
D
复制新的 xampp驱动C
注意
在 phpmyadmin 的“导出数据库”选项卡上,选择“UTF-8 字符”并选中“禁用外键检查”复选框
并在导入选项卡上取消选中
启用外键检查
。I just upgrade my old XAMPP portable with PHP 5.3.X(Include Mercury & FileZilla & Tomcat) to XAMPP portable with PHP 5.6.X ( Include previous versions ) ...
My way:
max_upload_size
and etc on php.ini and also in/apache/conf/extra/httpd-xampp.conf
D
to driveC
NOTE
On Export database tab on phpmyadmin, select UTF-8 Character and check
Disable foreign key checks
checkboxand on import tab uncheck
Enable foreign key checks
.1) 备份您的 htdocs 文件夹
2) 导出数据库(按照此教程进行操作)
3) 卸载xampp
4)安装新版本的xampp
5) 替换您已备份的 htdocs 文件夹
6) 导入您之前导出的数据库
注意:如果您更改了配置文件,例如 PHP (php.ini)、Apache (httpd.conf) 或任何其他文件,请备份也删除这些文件并将其替换为新安装的版本。
1) Backup your htdocs folder
2) export your databases (follow this tutorial)
3) uninstall xampp
4) install the new version of xampp
5) replace the htdocs folder that you have backed up
6) Import your databases you had exported before
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.
要在 xampp 中更新最新的 PHP 版本而不丢失 htdocs 数据,您需要从 sourceforge.net 下载所需 PHP 版本的 zip 文件,然后从提取的文件中复制 PHP 文件夹并将其粘贴到您的 xampp 文件夹中。
注意:不要忘记重命名已存在的旧 PHP 文件夹。
然后只需使用当前路径编辑 php.ini 文件即可到达正确的 PHP 文件夹。
之后,您需要重新运行 xampp。
我在 youtube 上找到了一个视频,可以帮助你。
如何更新xampp中的php版本
To update with latest PHP version in xampp without losing your htdocs data you need to download the zip file of your desired version of PHP from sourceforge.net, then copy the PHP folder from the extracted file and paste it into your xampp folder.
NOTE: Don't forget to rename the old PHP file folder which already exists.
Then simply edit your php.ini file with the current path to reach the right PHP folder
After that, you need to re-run your xampp.
I found a video on youtube which can help you.
how to update php version in xampp
如何正确更新 XAMPP 和 PHP 8.x
请注意,不建议将 XAMPP 中的旧版本 PHP 替换为新版本,因为这可能会由于以下原因而引入问题和不兼容问题:不打算一起使用的工具、配置和代码库。
相反,更新 XAMPP 的 PHP 版本的安全、推荐的方法是将其连同 PHP 需要使用的二进制文件(即 MySQL 和 PHPMyAdmin)一起更新到与 PHP 版本兼容的版本。通过这种方式,您还可以利用更新到新版本的安全性和速度优势 - 例如,现代版本的 PHPMyAdmin 比几年前的版本要快得多,而且错误少得多。
不幸的是,没有简单的方法来更新 XAMPP,考虑到它作为一个项目的历史和成熟度,这很奇怪,但下面的步骤概述了最简单的方法。
将当前工作的
XAMPP
文件夹(默认位于C:\xampp
)重命名为XAMPP.old
或类似的名称以指示这是旧版本。下载您想要的 XAMPP/PHP 版本的 XAMPP 安装程序( XAMPP 版本镜像 PHP 版本,以便更轻松地了解您所获得的 PHP 版本),并将其安装到
C:\xampp
。完成安装过程,随意取消选择任何不需要的软件(例如 Mercury Mail 和 Tomcat),以防止它们扰乱您的安装,然后等待安装完成。
从
C:\xampp
中删除以下文件夹,并从C:\xampp.old
中复制并粘贴其等效项:您现在已将所有网站和数据库数据移至从您上次安装开始,因此如果您没有对 XAMPP 配置进行太多自定义或不关心将配置移过来,您可以在此阶段停止,您将在新版本上运行完整的 XAMPP 安装PHP 以及与其兼容的新软件。
接下来,您需要将配置文件从位于
C:\xampp.old
的旧 XAMPP 安装复制到位于C:\xampp
的新安装。首先是
php\php.ini
文件 - 该文件不应该简单地复制,因为它包含特定于当前 PHP 安装的配置选项。如果您对其进行了更改或者不确定是否进行了更改,则可以使用 diff 工具,例如diff --color -y
将旧的php.ini
文件与刚刚安装的文件进行比较 - 如果您看到任何红色行,这些是您可能需要复制到新的C:\xampp\php.ini
文件中的行,但请注意,其中许多行可能是不必要的 - 通常它们会被开发人员删除,因为它们新的 PHP 版本不再需要。剩余的配置文件和文件夹可以简单地复制到
C:\xampp
上的相同位置,替换较新的版本:所有这些更改都应该非常安全,但最好保留当您测试新的 XAMPP 服务器时,
C:\xampp.old
文件夹会保留几周。如果发现您遗漏了某些内容,您可以稍后将其复制过来。您现在应该能够打开 XAMPP 控制面板来启动服务器并确认新版本的 Apache 和 MySQL 正在运行,并访问 localhost/phpmyadmin 来确认最新版本的 PHPMyAdmin 已安装安装成功。最后,运行 php -v 来确认您使用的是已安装的 PHP 版本。
How to properly update XAMPP and PHP 8.x
Note that it's not recommended to just swap out an older version of PHP in XAMPP to a newer version, as there's the possibility it could introduce problems and incompatibilities due to tools, configurations and codebases that weren't intended to be used together.
Instead, the safe, recommended way to update XAMPP's PHP version is to update it along with the binaries that PHP needs to work with - namely MySQL and PHPMyAdmin - to versions that are compatible with the version of PHP. This way you will also be able to take advantage of the security and speed advantages of updating to newer versions - for example, modern versions of PHPMyAdmin are miles faster and much less buggy than versions that are a few years old.
Unfortunately there is no easy way to update XAMPP, which is bizarre considering how old and mature it is as a project, but the steps below outline the easiest way to do so.
Rename your current, working
XAMPP
folder (located atC:\xampp
by default) toXAMPP.old
or something similar to indicate it's the old version.Download the XAMPP installer for the version of XAMPP/PHP you want (the XAMPP version mirrors the PHP version to make it easier to know which PHP version you're getting), and install it to
C:\xampp
.Go through the install process and feel free to deselect any software you don't need - like Mercury Mail and Tomcat - to prevent them cluttering up your installation, then wait for the install to complete.
Delete the following folders from
C:\xampp
and copy and paste their equivalents fromC:\xampp.old
:You've now moved all of your website and database data over from your last installation, so if you didn't customise your XAMPP configuration a lot or don't care about moving your configuration over, you can stop at this stage and you will have a fully-working installation of XAMPP running on your new version of PHP, along with new software that is compatible with it.
Next, you need to copy over the configuration files from your old XAMPP installation at
C:\xampp.old
to the new one atC:\xampp
.First is the
php\php.ini
file - this file should not simply be copied over, as it contains configuration options that are very specific to the current PHP installation. If you've made changes to it or you're not sure whether you have, you can use a diff tool likediff --color -y <old php.ini> <new php.ini>
to compare your oldphp.ini
file with the one you just installed - if you see any lines in red, these are the lines you might need to copy over to your newC:\xampp\php.ini
file, although note that even many of these might be unnecessary - usually they are removed by the developers because they're no longer needed by the newer PHP version.The remaining configuration files and folders can simply be copied below into the same locations on
C:\xampp
, replacing the newer versions:All of these changes should be pretty safe but it's always a good idea to keep the
C:\xampp.old
folder around for a few weeks while you're testing out your new XAMPP server. If it turns out you missed something you can then just copy it over later.You should now be able to open the XAMPP Control Panel to start the server and confirm that your new versions of Apache and MySQL are working, and visit
localhost/phpmyadmin
to confirm that the latest version of PHPMyAdmin has been installed successfully. Finally, runphp -v
to confirm that you're on the installed version of PHP.1) 从官方网站下载新的 PHP(最好是 zip)。旧的
php
目录重命名为php_old
并再次创建php
目录并将解压缩的文件放在那里。如果您使用默认情况下关闭的内容(例如 Memcached 等),请在 php.ini 中连接所需的模块,但不要忘记添加相应的 .dll 文件。
2) 就我而言,我必须更新 Apache。因此,重复相同的步骤:下载新包、重命名目录、创建新的 apache 目录并放入新文件。
现在,您可以尝试从
xampp
文件夹中运行apache_start.bat
重新启动 apache(最好运行此bat,而不是从 Windows 服务窗口重新启动 apache 服务,因为在这种情况下,在控制台中您如果有的话,会看到所有错误,包括配置中出现问题的行)。如果您更新了 Apache 并运行此文件,在服务列表中您将看到 Apache2.2,但在描述中您可以获得另一个版本(在我的例子中是 Apache/2.4.7)。如果 Apache 更新,您可能会遇到一些问题,因此请注意:
替换整个目录后,您可能需要配置
apache/conf/httpd.conf
文件(从旧配置,设置 DocumentRoots,目录权限,所有路径,扩展索引文件列表(默认情况下 apache 只有index.html
所以其他索引文件将被忽略,Apache 将仅列出 从连接您需要的模块(如果您使用了默认情况下未打开的模块,例如 mod_rewrite 等)
1) Download new PHP from the official site (better some zip). Old
php
directory rename tophp_old
and create againphp
directory and put there unzipped files.In
php.ini
connect needed modules if you used something that was turned off by default (like Memcached etc.), but doesn't forget to add corresponding.dll
files.2) In my case, I had to update Apache. So repeat the same steps: download the new package, rename directories, create new
apache
directory and put their new files.Now you can try to restart apache running
apache_start.bat
fromxampp
folder (better run this bat, than restart apache service from Windows services window, cause in this case in console you'll see all errors if there will be some, including lines in config where you'll have problem). If you updated Apache and run this file, in the list of services you'll see Apache2.2, but in description you can get another version (in my case that was Apache/2.4.7).In case of Apache update you can get some problems, so mind:
after you replace the whole directory, you may need to configure you
apache/conf/httpd.conf
file (copy virtual hosts from old config, set up DocumentRoots, permissions for directories, all paths, extend the list of index files (by default apache has onlyindex.html
so other index files will be just ignored and Apache will just list the site root directory in browser), configure you logs etc.)connect modules you need (if you used something that was not turned on by default like mod_rewrite etc.)
注意
为了在升级后运行 apache 服务器,PHP 7.4.x 需要 Microsoft Visual C++ Redistributable for Visual Studio 2019,可以下载 此处标题下 其他工具和框架。否则apache服务器将无法启动。
Note
In order to run apache server after upgradation PHP 7.4.x requires Microsoft Visual C++ Redistributable for Visual Studio 2019 which can be downloaded here under the heading Other Tools and Frameworks. otherwise apache server won't start.
对于 Xampp 中的升级 php,您可以按照以下步骤操作,否则您可以跳过这 4 个步骤并直接从 网站,这里是 直接下载链接
第 1 步: 进行备份
在开始之前,请确保备份所有设置、自定义模块以及最重要的 htdocs 目录,其中包含脚本和页面资源。该目录通常位于 C:\xampp\htdocs\
第 2 步: 准备工作
下载 PHP 5.3.0rc2。我使用 VC6 构建是为了最大限度地减少任何潜在的兼容性问题。
还建议您下载最新的 Windows 版本的 XAMPP。虽然这是一个适用于以前版本的 XAMPP 的升级指南,但建议使用核心文件的全新副本。
停止任何可能正在运行的 Apache 服务实例。
第 3 步:升级
本指南将假设您的 XAMPP 目录为 C:\xampp\
将 XAMPP 存档提取到您选择的目录,我建议使用默认的 C:\xampp\
将 PHP 存档的内容提取到 C:\xampp\php\,用新文件覆盖该目录的内容。
打开文件 C:\xampp\apache\conf\extra\httpd-xampp.conf 并确保以下行按此顺序出现:
执行上述步骤后,重新启动 Apache 服务(可以使用 C:\xampp\xampp-control.exe 或通过控制面板/命令提示符手动完成)。您的 PHPinfo 应该表明升级已成功。
如果我发现使用此方法或执行升级的更干净(自动)方法有任何问题,我将更新这篇文章。
For Upgradation php in Xampp you can follow this steps, Else you can skip these 4 steps and direct install MAMP (for windows as well) from site and here is the direct download link
Step 1: Make backups
Before starting, make sure to backup any settings, custom modules and most importantly the htdocs directory, which contains your scripts and page resources. This directory is normally located atC:\xampp\htdocs\
Step 2: Preparation
Download PHP 5.3.0rc2. I use the VC6 build in order to minimise any potential compatibility issues.
It is also recommended that you download the latest Windows version of XAMPP. While this is an upgrade guide that shouldwork with previous versions of XAMPP, it is recommended that a fresh copy of the core files is used.
Stop any instances of the Apache service that might be running.
Step 3: The upgrade
This guide will assume your XAMPP directory is C:\xampp\
Extract the XAMPP archive to a directory of your choosing, I would recommend using the default C:\xampp\
Extract the contents of the PHP archive to C:\xampp\php\, overwriting the contents of this directory with the new files.
Open the file C:\xampp\apache\conf\extra\httpd-xampp.conf and ensure the following lines are present in this order:
After following the above steps, restart your Apache service (this can be done using C:\xampp\xampp-control.exe or manually through the control panel/command prompt). Your PHPinfo should indicate that the upgrade has been successful.
I will update this post if I discover any problems from using this method, or a cleaner (automated) means of performing the upgrade.
备份您的 htdocs 和 data 文件夹(MySQL 文件夹的子文件夹),重新安装升级版本并替换这些文件夹。
注意:
如果您更改了 PHP (php.ini)、Apache (httpd.conf) 或任何其他配置文件,请同时备份这些文件并将其替换为新安装的版本。
Take a backup of your htdocs and data folder (subfolder of MySQL folder), reinstall upgraded version and replace those folders.
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.
在
XAMPP
中升级PHP
的最简单方法:XAMPP
。XAMPP
的位置)。PHP
文件夹。XAMPP
目录中的PHP
文件夹。您可以备份它,就像将PHP
文件夹名称更改为PHP-old
或就像
PHP-version-number
PHP
文件夹。php.ini
文件替换为备份文件夹php.ini
文件。服务器
。Simplest method to upgrade
PHP
inXAMPP
:XAMPP
.XAMPP
already installed).PHP
folder from the extracted archive.PHP
folder which is in installedXAMPP
directory. You can backup it like changing thePHP
folder name toPHP-old
orlike
PHP-version-number
PHP
folder which you copied from the extracted archive.php.ini
file with your backup folderphp.ini
file in case you have changed the default settings earlier.server
.您可以浏览以下链接,因为它对我有帮助,也应该对您有用。 http://hype-free.blogspot .com/2007/07/updating-php-in-xampp-for-windows.html
意识到我的答案帮助了几个用户,这里是原始链接的编辑:
编辑:
首先始终备份您的数据。
注意:XAMPP安装中有两个目录需要更新新版本的文件,即
php
子目录和apache/bin
子目录。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
Realizing that my answer helped couple of users, here is the edit from original link:
Edit:
First of all Always backup your data.
NOTE: there are two directories to be updated with new version of files, namely
php
sub-directory andapache/bin
sub-directory, inside XAMPP installation.从 php5.6 升级到 php7.2
我已按照我所遵循的步骤
5.1。代替
到
I have upgraded to php7.2 from php5.6
Steps which I followed.
5.1. Replace
to
我需要将我的 php 从 5.3.8 更新到 5.3.29。 (均为线程安全)在 Windows 上
我所做的步骤:
http://windows.php.net/download/#php-5.3-ts-VC9- x86
从旧的。例如:extras,其中包含browscap.ini文件
(需要这个)
ext 文件夹。我通过检查 php.ini 文件中的扩展列表来手动复制它们。
希望我涵盖了所有内容。
如果您更改 php 的主要版本(例如 5.3.x 到 5.4.x),这些步骤很可能不起作用,但对于次要版本,它应该起作用。
另外,这是查看问题所在的好方法...启动命令行并尝试在 xampp/apache/bin 下启动 httpd.exe,它将列出发现的错误。
I needed to update my php from 5.3.8 to 5.3.29. (both Thread Safe) on Windows
Steps I did:
http://windows.php.net/download/#php-5.3-ts-VC9-x86
from old one. For example: extras, which contained browscap.ini file
(this one is needed)
ext folder. I copied them manually, by checking list of extensions from php.ini file.
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.
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.
我认为您需要实际下载并安装具有所需 PHP 版本的 XAMPP。我认为您不能单独升级 XAMPP 的组件,除非 XAMPP 本身提供了为此提供的工具。
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.
从 http://windows.php.net/download/ 网站下载所需版本的 php 二进制文件。下载线程安全二进制 zip 版本。
将下载的 PHP 版本解压到单独的文件夹中。
请确保您的新 php 文件夹名称不是“PHP”。也许您可以使用文件夹名称作为版本名称。例如,对于 php 5.4,您可以使用 php54。
将新的 php 文件夹复制到您的 xampp 文件夹中。现在转到您的 xampp/apache/conf/extra 文件夹。从 extra 文件夹中打开文件 httpd-xampp.conf。更改以下变量:
变量 PHPINIDir 为 /
变量 LoadModule 为 //php5apache2_2.dl
保存文件 httpd-xampp.conf。重新启动您的 XAMPP apache 服务器。如果您的服务器成功重新启动,则您的服务器 php 版本已升级。
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.
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:
Variable PHPINIDir to be /
Varaible LoadModule to be //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.
我还没有足够的声誉来发表评论,但是,要添加到 ssharma 的答案中:
将 htdocs 文件夹复制到安全位置后,只需从 PHPmyadmin 导出数据库即可。只需转到每个数据库并单击顶部的导出选项卡即可。将它们导出为 sql(或其他任何形式,实际上 - 只需记住您选择的内容即可)。升级您的 XAMPP 安装。现在,在新版本的 XAMPP 中,创建要重新插入的数据库。示例:您有一个从旧安装中导出的名为“test”的数据库,将新的空数据库命名为相同的名称。现在,进入“测试”并点击顶部的导入按钮(导出按钮旁边)。单击“选择文件”,找到之前导出的 sql 文件(应为“test.sql”)并导入。您的表格和数据将就位。
注意:有一个选项可以导出整个数据库集合(其将文件命名为 127.0.0.1.sql)。但是,我从来没有运气好让它正确导入。分别执行每个数据库以确保其正常工作。我写这篇文章有点啰嗦,但那是因为我喜欢为那些还不知道自己在做什么的人写作(我本人不久前也在那里(我们所有人都在某个地方)观点))。
我的答案的简写版本:
1) 单独导出您的数据库
2) 导入到新安装的 XAMPP 中
I don't have enough reputation to comment yet, but, to add to ssharma's answer:
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.
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)).
Shorthand version of my answer:
1) Export your databases individually
2) Import into your new installation of XAMPP
phpinfo()
,按 ctrl+f,然后输入thread
检查值。php
。php
文件夹重命名为其他名称。php
)文件夹复制到 xampp 目录中。php
文件夹(您重命名的)复制php.ini
文件,并将其粘贴到新的php
文件夹中。phpinfo()
, press ctrl+f, and typethread
to check the value.php
.php
folder to something else.php
) folder in xampp directory.php.ini
file from default/oldphp
folder (That you renamed) and paste it into the newphp
folder.