How to Update PHP Version on XAMPP (Windows)?

Being a web developer myself, XAMPP is probably one of the software that I use mostly on my Windows computer. I will not go into details to explain why I use XAMPP and why you should consider using it too. While it took me a while to figure out how to update the PHP version, I though it will be helpful to share my experience and make your job easier and save you lot of time on this task. This article is dedicated to show you different options on how to update the PHP version on XAMPP Windows and fix any problem that may come along.
Why You Should Update XAMPP PHP Version?
Just like with any other software, with PHP it is also highly recommended to use the latest version. The new PHP7 version has lots of improvements, compared to the old PHP5. PHP7 uses half of the memory and its performance has been improved significantly. Here are some other benefits of using PHP7:
- PHP 7 is almost twice as fast as lower version of PHP
- Low memory usage (up to 50%)
- Facilitates Error Handling
- 64-Bit Windows Systems Support
- New Spaceship and Null Coalescing Operators
- Enables Accurate Type Declarations
- Add Anonymous Classes
- Facilitates Imports From the Same Namespace
- Introducing null coalescing & Spaceship operator and more
On the other hand PHP5 version will not be supported for much longer. For instance, Joomla 4 will be compatible only with server that are using at least PHP7 version. These are only couple of reasons, but you get the point.
Update PHP version on Windows XAMPP
If you are running an older version of XAMPP (3.2.1 or older), most likely you are still using PHP5. Here are couple of options on how to upgrade old PHP5 version to PHP7.
-
Download the latest PHP version that is compatible with your Windows (x86 or x64)
-
Extract files to a folder named php
-
Go to your XAMPP installation directory and rename the old php folder (something like php_5)
-
Copy the recently extracted php folder to your XAMPP installation folder
-
Open up the XAMPP Control Panel and configure Apache
-
Click on Config button next to Apache module and choose Apache (httpd-xampp.conf)
-
Replace all php5 with php7 text and save the file
-
Restart Apache server!
What if the Apache server does not start? You might get the following error message on your XAMPP Control Panel:
If so, please do the following:
-
In the XAMPP Control Panel click the Config button next to Apache module
-
Choose Apache (httpd.conf)
-
Find and replace the following lines:
Listen 80
to
Listen 8080
ServerName localhost:80
to
ServerName localhost:8080
-
Save and close the httpd.conf file
-
Edit the httpd-ssl.conf file by clicking the Apache (http-ssl.conf)
-
Find and replace the following lines:
Listen 443
to
Listen 4443
<VirtualHost _default_:443>
to
<VirtualHost _default_:4443>
ServerName www.example.com:443
to
ServerName www.example.com:4443
-
Save and close the httpd-ssl.conf file
-
Restart Apache server
If you did everything right, the Apache server should start.
At this point one more error could stop you using the XAMPP Apache server:
Missing DLL Problem with XAMPP
This error is due to outdated Microsoft Visual C++ software. The error could still persist, even though you might have this software installed to your computer.
Here is what you can do:
-
Download the latest version of Microsoft Visual C++
-
Uninstall the old version from your computer: Start > Control Panel > Programs Uninstall a Program
-
Restart your computer
-
Install the new version that you recently downloaded
-
Restart your computer again
-
Launch the XAMPP Control Panel and start the Apache server – the .dll error should not pop up anymore
Install XAMPP 3.2.2
If none of the above methods work, I suggest installing the latest version of XAMPP. The latest version of XAMPP (3.2.2) comes with PHP7 included, so you don’t have to mess with all the above problems. But be careful, not to overwrite your old files, because you might lose all your projects, files and databases. Here is an easy to follow step-by-step guide on how to install the new XAMPP and transfer your projects over:
-
Go to AppacheFrineds.org and download the version that you need
-
Run the installation and choose a different destination folder for it – if your old XAMPP version is installed to C:/xampp/ folder, install the new version to C:/newxampp/
-
After successful installation transfer the C:/xampp/htdocs/ folder to C:/newxampp/htdocs/ – this will transfer all of your project files to the new installation
-
Also transfer the C:/xampp/mysql/data/ to C:/xampp/mysql/data/ – this will transfer all database information to the new installation
-
Open the new XAMPP Control Panel v3.2.2 – and start Apache and MySQL
-
Now check the php version http://localhost/phpinfo.php – this PHP file should contain the following line:
<?php phpinfo(); ?>
-
Start using the power of PHP7!
Wrapping it up
I really hope this article has helped you. If you are still having difficulties, please let us know in the comments and will try to answer your queries and find a solution to your problem. Happy coding!
destroyed my xampp
Does it mean that this instruction will also allow one to change the platform of PHP bundled with XAMPP, specifically from 32-bit to 64-bit?
Please do not follow this… its gonna destroy your xampp
Hi! I was wondering what happen with your XAMPP. How it got destroyed? You can’t start Apache or MySQL? Sometimes it happens to me as well, that Apache won’t start after restarting my computer. I fix this by accessing the httd.conf and httpd-ssl.conf and change all ports: 80 to 8080 and 443 to 4443 or vice-versa.
I upgraded XAMPP using this method on multiple computers and never had any issue.
Please let me know what is your issue, so we can update the tutorial.
I did it step by step as you reached. But still get error message. I already changed php5->php7,80->8080, 443>4443. It doesn’t work for me. By the way, I download php7.3.
4:40:16 PM [Apache] Attempting to start Apache app…
4:40:17 PM [Apache] Status change detected: running
4:40:19 PM [Apache] Status change detected: stopped
4:40:19 PM [Apache] Error: Apache shutdown unexpectedly.
4:40:19 PM [Apache] This may be due to a blocked port, missing dependencies,
4:40:19 PM [Apache] improper privileges, a crash, or a shutdown by another method.
4:40:19 PM [Apache] Check the “/xampp/apache/logs/error.log” file
4:40:19 PM [Apache] and the Windows Event Viewer for more clues
I found that sometimes Apache won’t start when Skype or Thunderbird are open. Try starting the Apache server after you close all programs.
I did not tried it with PHP 7.3, currently I use PHP 7.2.6 with XAMPP v3.2.2
Can you also paste what the error.log file contains?
After doing your steps caught in issues. My localhost was working fine and the urls are also working ex-
Previously
localhost/project/ -> It open the index.php
After update
It open the page but code is visible over the browser. If i want to run the file then i have to add the index.php at last.
Why this is happening
This will not work, the idea of changing ports doest not relate to the upgrade but to another instance of apache running or using the same port. You need to stop everything after you finish and check in the task bar that there are no instance running (sometimes the old XAMPP control leaves running apache even it says closed).
Aside of this, the php.ini need to be updated since it appears that apache is loading by detail the library php_intl.dll. To solve this is easy, just uncomment the line in the php ini that loads the libraries that cannot be found.
But in conclusion, I would not follow all this steps blindly and maybe try to update the steps, there is something missing that I also couldn’t find.
wrong information given here it does not work on changing just port.. I have tried long hrs does not work dont follow this article.
Your tutorial sucks… remove it!
Followed every step and still doesn’t work…
this destroyed my xampp i had to install it again
destroyed my xampp also lol.
cant access my mysql n phpmyadmin.
i dont know what to do now.
just remove the changes that you did and put was there before, it will work again don’t worry
Sir i tried it and it is working fine by downloading php 7.2 and replacing php to new php folder but the issue is that the new php does not has php.ini file and after checking the info.php i found that (Loaded Configuration File (none)).That means the php.ini file does’t exist so now please tell me what to do?
Don’t follow this.
It destroyed my xampp and mysql. Lost everything
After following the instructions and updating, I was experiencing the issue others had had regarding Apache not starting up. My solution was to complete the Xampp reinstallation process as described here, copy the old xampp file somewhere else for backup, then go into the remaining old xampp folder in the hard drive and delete everything except the folders that are accessed by Filezilla, data, mysql, then go into the newxampp folder and copy all the contents and paste it into the old, empty xampp folder. This worked.
PhpMyAdmin does not work before following these post…
Hahaha, I wish I had read the comments BEFORE updating following the steps described above. In the end I re-installed XAMPP to the latest version and it all took a few minutes rather than the hour or two I spent mucking around with trying to update PHP separately.
There is definitely some steps missing in this tutorial…
Xampp stopped working… guys do follow these instructions. Otherwise you will lost your working copy….
Why i do not read comment first 🙁
My xampp not working now :'(
works fine for me
thanks men
Lejos de destruir el XAMP con estas instrucciones. existe un error. los puertos en php 7 y php5 deben ser 80 y 443 (los asigna apache).
la carpeta php7 descargada. va remplazando los archivos en c:/xamp/php
“SE DEBE SOBREESCRIBIR” y listo, en teoria no hay que hacer nada más.
reiniciar el servicio de apache y ya.
Thank you for your feedback Erick! Here is the translated version of what Erick just wrote in the comment above:
Far from destroying the XAMP with these instructions. There is an error. the ports in php 7 and php5 must be 80 and 443 (assigned by apache).
The php7 folder downloaded. it replaces the files in c: / xamp / php
“MUST OVERWRITE” and voila, in theory you do not have to do anything else.
restart the apache service and now.