Xampp PHP version update
The detailed steps to update the PHP version in XAMPP are as follows:
Step 1: Download the new version of PHP
- Open PHP official download page。
- Choose the appropriate PHP version for your operating system, making sure to download the "Thread Safe" ZIP archive for XAMPP.
- If you are using Windows, usually download the "Windows x64" or "Windows x86" version.
- After downloading, extract the ZIP file to a temporary folder for later use.
Step 2: Back up old PHP files
-
Open the XAMPP installation directory (usually
C:\xampp). -
Find the
phpfolder in it, for exampleC:\xampp\php. -
To back up the old version, copy
phpRename the folder to
php_old(or any other name you like, such as
php_backup).
- This step ensures that old PHP files are not lost and can be restored at any time.
Step 3: Copy the new PHP files to XAMPP
-
Copy all the contents of the new PHP folder you just unzipped.
-
Create a new
phpfolder in the XAMPP installation directory, for exampleC:\xampp\php. -
Paste all the files in the new PHP folder into this
phpfolder.
Step 4: Update the php.ini configuration file
-
Find and open the
php.ini-developmentorphp.ini-productionfile in the newphpfolder. -
Rename the file to
php.ini. -
If necessary, you can rename it according to the previous version
php_old\php.iniFile configuration to adjust the new
php.ini, for example, modify:
-
max_execution_time: the maximum time for script execution. -
memory_limit: the maximum memory usage allowed by PHP. -
upload_max_filesize: the maximum file size allowed for upload.
Step 5: Update Apache configuration files (optional)
-
Open the
C:\xampp\apache\conf\extradirectory. -
Find and edit the
httpd-xampp.conffile. -
Find
LoadModule php_moduleconfig line, making sure it points to the path to the new version of PHP, for example:
LoadModule php_module "C:/xampp/php/php8apache2_4.dll"
- You need to ensure that the
.dllfiles contained in the new PHP folder are compatible with the version of Apache.
Step 6: Restart XAMPP
- Open the XAMPP control panel.
- Click "Stop" to stop the Apache service, and then click "Start" to restart Apache.
- Check if Apache is running properly and there are no errors.
Step 7: Verify PHP version
-
Create a new
phpinfo.phpfile in thehtdocsdirectory of XAMPP (for example,C:\xampp\htdocs). -
Enter the following content in the file:
<?php
phpinfo(); -
Visit
http://localhost/phpinfo.phpin your browser and check if the PHP information page shows the new version you installed.
Additional Tips
- Restore from old version: If there is a problem with the update, you can delete the new
phpfolder, rename thephp_oldfolder back tophp, and restart Apache. - Apache configuration file backup: Before modifying
httpd-xampp.conf, it is best to back up the original file.
After completing these steps, your XAMPP will use the new version of PHP!