I have a Windows 10 laptop with Apache, PHP8 and MariaDB, but I need to develop a site with PHP7. I’ve never run two different versions of PHP on the same machine before, so if anyone can help please chime in.
There’s an article here about that, though it recommends Nginx instead of Apache:
Then I also found a newer post at SO:
Thanks. I can’t seem to find anything Windows-specific. I’m better off simply downgrading to 7.4.x. Apparently Microsoft is pulling support for 8 anyway, so no point going there. Disappointing.
Some search results was about running multiple WAMP or XAMPP on the same box.
If that could solve anything?
You could look at Laragon, although at present swapping to v8 isn’t quite as easy as it should be.
For some reason I could never get WAMP or XAMPP running on any machine I ever owned. I build the server environment on my own from scratch, and it works.
I’ve decided to roll back to PHP7, since 8 isn’t widely supported yet, and because of Microsoft’s odd decision.
Thanks for the input guys.
Laragon would be the the easiest solution for installing multiple Php versions. While switching between Php 7 and 8 currently has a slight flaw, it is only a minor inconvenience to switch between the two.
For Php8 to work in Laragon edit C:\laragon\etc\apache2\mod_php.conf change php8_module to php_module
The file is auto-generated so you will have to edit it everytime you switch to another Php version and then back to version 8
Apache must be stopped and then started, not restarted
I understood the php.ini file also needs editing.
When you you use the Laragon GUI to switch the version, it reads from the ini that is in the version xxx dir. Each version has it’s own .ini. The only edit needed to use version 8 is just what I posted.
If you want the same settings between versions, then you may need to edit each versions ini.
Actually depends on which operating system you’re using. I don’t use Windows anymore and rarely use Linux, but on macOs, you can theoretically change between different versions using Homebrew. I actually think it’s possible for all operating systems in simple terms.
I’ve created a topic thread a while back on how to manually install PHP using the method I use. Switching between PHP versions on Windows is pretty easy if you install it the way I did in the topic. All you really need to do is download the PHP binaries from the official PHP website. Then just rename the folder to
PHP whenever you want to switch to a different version and restart Apache. Simply put, the folder for PHP in the demo videos on that topic points to
So in theory, the only hard part about this is renaming the folders. And I’m pretty sure you know how to do that. But if you’re talking about running both PHP 7 and PHP 8 on different instances and have them run at the same exact time, I don’t really know if that’s possible.
From the OP…
I use WAMP so I can easily switch between versions.
Possible by the use of virtual machines (different virtual machine for each HP version being used)
That still means they’re on different machines since each VM is instances of separate operating systems.
Now that I think about it, I think it is actually possible to run 2 PHP instances on the same computer. When you install Apache, you just need to rename the service. Then you’d need to download and install another Apache service under a different name and different port. The reason is because it all boils down to the DLL file you’re loading in for PHP. They have to be from different locations if you want to run 2 different PHP instances. Hence why it theoretically work with 2 different instances of Apache.
If I could interject, yes, Microsoft is no longer going to support newer versions of PHP going forward, however, the PHP team still makes binaries for Windows:
After finally being available after a few days, I tested my theory and turns out it is possible to run 2 versions of PHP simultaneously. The first instance of Apache (has the
php8apache2_4.dll file) runs on the default port 80 while the second instance of Apache (has the
php7apache2_4.dll file) runs on port 8080.
Nice work! Thanks for making the video. Guess I can keep my 7 and add the 8 again.
If you have a spare 20Gb on your hard-drive then consider installing a dual Boot Linux Operating System. Most Linux operating systems can be first tried using a USB and then installed alongside Windows.
I use Ubuntu and swap PHP versions using the following batch files run from the command line::
#!/bin/bash # Usage: ~/./php-7.sh sudo a2dismod php8.0 sudo a2enmod php7.4 systemctl restart apache2
#!/bin/bash # Usage: ~/./php-8.sh sudo a2dismod php7.4 sudo a2enmod php8.0 systemctl restart apache2