Multiple PHP Versions and XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Multiple PHP Versions and XAMPP

Postby g2ktcf » 02. January 2022 16:21

I am trying to setup a development environment and need PHP 7.4, 8.0 and 8.1. I tried installing different versions of XAMPP in different directories (/xampp, /xampp2 and /xampp3) but had all kinds of issues. I may have been missing something BUT I also do not want to keep multiple copies of the files and databases. I have seen how to install multiple PHP versions like xampp/PHP (orginal install, say 7.4) and xampp/PHP8 and xampp/PHP81. They all say to download the correct version...I know I need thread safe, but do I download the normal thread safe one or the "debug" version. I have never done this before so I am a bit lost.

I am using XDebug and Netbeans on a local Windows 10 laptop in case that matters.

Thanks in Advance.
g2ktcf
 
Posts: 7
Joined: 01. January 2022 17:29
XAMPP version: 8.0.30
Operating System: Windows 11

Re: Multiple PHP Versions and XAMPP

Postby Altrea » 02. January 2022 17:44

g2ktcf wrote:I have seen how to install multiple PHP versions like xampp/PHP (orginal install, say 7.4) and xampp/PHP8 and xampp/PHP81. They all say to download the correct version...I know I need thread safe, but do I download the normal thread safe one or the "debug" version.

the normal one
i have written a step by step tutorial years ago which should still work, bit its om german though
https://community.apachefriends.org/f/viewtopic.php?f=4&t=67753#p232615
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11954
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Multiple PHP Versions and XAMPP

Postby g2ktcf » 03. January 2022 18:32

Perfect. I got the php versions downloaded. I am trying to get Google to translate (and it seems to work okay). How would you switch between php versions?
g2ktcf
 
Posts: 7
Joined: 01. January 2022 17:29
XAMPP version: 8.0.30
Operating System: Windows 11

Re: Multiple PHP Versions and XAMPP

Postby Nobbie » 03. January 2022 19:01

As already mentioned in the links, i would create different VirtualHosts for different PHP Versions. No switch necessary, only different ServerNames.

P.S.. I dont recommend Google for translating. Use deepl.com instead, by far the best engine ever.
Nobbie
 
Posts: 13233
Joined: 09. March 2008 13:04

Re: Multiple PHP Versions and XAMPP

Postby Altrea » 03. January 2022 19:16

g2ktcf wrote:Perfect. I got the php versions downloaded. I am trying to get Google to translate (and it seems to work okay). How would you switch between php versions?

Switching is pretty easy. All the switch magic happens in the .htaccess file you put into the folder.
So if this settings are not there, the Apache module version would be executed.

You can of cause place this .htaccess directives into a virtualhost too instead. this is up to you. virtualhost changes need a Apache restart, .htaccess Changes not, but they are slower to process.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11954
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Multiple PHP Versions and XAMPP

Postby g2ktcf » 03. January 2022 20:00

Everything I have read about virtual hosts makes me think that I need a different htdocs folders for this to work. I need to run the same files on different php versions.

.htaccess Datei im Verzeichnis deiner Wahl mit folgendem Inhalt erstellen


Translates to (for me at least)

Create .htaccess file in the directory of your choice with the following content


Sorry, but folder of your choice is not very specific and I am trying to run THREE different versions of PHP. Do I need a different .htaccess folder for each version of PHP in the that PHP version's folder? I hate to sound stupid but I have no idea what these changes do as I have NEVER been able to understand .htaccess files.

I have C:/xampp/php for 7.4.24 installed as the base
I have C:/xampp/php8 for 8.0.14 files extracted to this folder
I have C:/xampp/php81 for 8.1.1 files extracted to this folder

I have added the following to the very end of my httpd-xampp.conf file.
Code: Select all
ScriptAlias /php8-cgi/ "C:/xampp/php8/"
<Directory "C:/xampp/php8">
    SetEnv PHPRC "C:/xampp/php8"
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
          Require all granted
    </Files>
</Directory>

ScriptAlias /php81-cgi/ "C:/xampp/php81/"
<Directory "C:/xampp/php81">
    SetEnv PHPRC "C:/xampp/php81"
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
          Require all granted
    </Files>
</Directory>


for the .htaccess files, do I create this one for PHP 8.0.14 and put it in the /php8 folder and similarly for the 8.1.1 version?

Code: Select all
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php-cgi
</FilesMatch>

<IfModule actions_module>
    Action application/x-httpd-php-cgi "/php8-cgi/php-cgi.exe"
</IfModule>
g2ktcf
 
Posts: 7
Joined: 01. January 2022 17:29
XAMPP version: 8.0.30
Operating System: Windows 11

Re: Multiple PHP Versions and XAMPP

Postby Altrea » 03. January 2022 22:05

g2ktcf wrote:Everything I have read about virtual hosts makes me think that I need a different htdocs folders for this to work. I need to run the same files on different php versions.

virtualhosts simulate different Apache httpd configurations without the need of installing multiple Apache httpd Servers.
This could be different domain names, which is the main purpose. But you can also configure different PHP implementations for the same DocumentRoot with help of virtualhosts.
virtualhosts are just a container with conditions for when it will activate (by IP, port or domain or a combination of them).
If your webapplication has a setting for the root url, domain or something similar (so if it generates the asset urls by itself) than virtualhosts are maybe not the way to go.

g2ktcf wrote:
.htaccess Datei im Verzeichnis deiner Wahl mit folgendem Inhalt erstellen


Translates to (for me at least)

Create .htaccess file in the directory of your choice with the following content


Sorry, but folder of your choice is not very specific

It cannot be that specific, because it really depends on your needs. In your case if you want to run a full webapplication with different PHP implementations, you surely want to place the .htaccess in your DocumentRoot directly. But if you want for example just one subfolder to be run with a different PHP version this .htaccess needs to be placed in this subfolder.
.htaccess directives will get inherited to subfolders as long as there is no other directive overriding the configurations.

g2ktcf wrote:and I am trying to run THREE different versions of PHP. Do I need a different .htaccess folder for each version of PHP in the that PHP version's folder?

No. Only one .htaccess in the DocumentRoot of your webapplication.

g2ktcf wrote:I hate to sound stupid but I have no idea what these changes do as I have NEVER been able to understand .htaccess files.

There is not much to understand. .htaccess files are a folder based condition to set Apache configuration directives. They get processed on request (instead of settings written in the Apache config files). Not all directives can be set in .htaccess files and you can limit the directives with help of the directive AllowOverride

For the rest of your questions, which i already mentioned: the .htaccess file needs to be placed in the DocumentRoot of your webapplication, not in the PHP folders.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11954
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

vRe: Multiple PHP Versions and XAMPP

Postby Nobbie » 03. January 2022 22:14

g2ktcf wrote:I hate to sound stupid but I have no idea what these changes do as I have NEVER been able to understand .htaccess files.


And why dont you get it? A .htaccess file actually can hold the same configuration lines as a Directory block in httpd.conf. No big difference.

You really should spend some time on working thru Apache documentation, and/or tutorials about configuration. I dont think you have spent lots of time. We cannot replace the need of learning the concecpts of Apache, including all basic configurations. It is not the goal of this forum to replace reading and learning about Apache. We cannot explain every option, every bit and byte of the Apache server. If you like to administrate Apache, you have to learn it. Even if you dont like it. You cannot administrate a webserver without any knowledge. Thats a sophisticated task and we can only help for technical issues, but we do not replace the Apache documentation.
Nobbie
 
Posts: 13233
Joined: 09. March 2008 13:04

Re: Multiple PHP Versions and XAMPP

Postby g2ktcf » 04. January 2022 13:11

Altrea,

This is quite helpful and I appreciate you taking time to explain it. I know what .htaccess files do, I just cannot read them, nor do I have time to read through all documentation. My problem was I did not understand how to switch between versions or the relationship between httpd-config and .htaccess.

I am working on a project in xampp/htdocs/store. So I need to put the .htaccess file (actually ADD to the existing .htaccess file) for PHP8 when I need to switch from 7.4? Stopping Apache, modifying that .htaccess file and restarting Apache is no big deal at all. I just do not want to screw this up.

This is a one off for me. I do not have any server control nor do I need it. I am simply developing a extensive new feature for a php based webstore and needed a local host to do testing. The current store works on PHP 7.4 - 8.0 and the new release is for 8.1.

Thanks!
Chris
g2ktcf
 
Posts: 7
Joined: 01. January 2022 17:29
XAMPP version: 8.0.30
Operating System: Windows 11

Re: Multiple PHP Versions and XAMPP

Postby Altrea » 04. January 2022 13:54

g2ktcf wrote:I know what .htaccess files do, I just cannot read them, nor do I have time to read through all documentation.

This problem needs to get solved by you. You need to take your time to learn basics you need to understand, at least the basics you want or need to use.
We might help explaining specific understanding problems, but we claim at least some sort of contribution from you reading and trying to understand the basics you are using.

g2ktcf wrote:I am working on a project in xampp/htdocs/store. So I need to put the .htaccess file (actually ADD to the existing .htaccess file) for PHP8 when I need to switch from 7.4?

yes.

g2ktcf wrote:Stopping Apache, modifying that .htaccess file and restarting Apache is no big deal at all. I just do not want to screw this up.

.htaccess file changes don't need a reastart of Apache.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11954
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Multiple PHP Versions and XAMPP

Postby g2ktcf » 04. January 2022 18:23

Works like champ!

Now to see if I can xdebug to work with all three versions. :)

And yes, I did read through the Apache documentation for the commands in the file. But I know so little about server configurations, I had no base of information to build off of.
g2ktcf
 
Posts: 7
Joined: 01. January 2022 17:29
XAMPP version: 8.0.30
Operating System: Windows 11

Re: Multiple PHP Versions and XAMPP

Postby jcadmin82 » 13. January 2023 16:23

Hi, I followed the instructions but it enables CGI on the second version. How would the config needs to be to usa Apache2 handler as Server API?
This is my config now at the end of https-xampp.conf:

Code: Select all
# PHP 7
ScriptAlias /php7/ "C:/xampp/php7/"
Action application/x-httpd-php7-cgi "/php7/php-cgi.exe"
<Directory "C:/xampp/php7">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
          Require all granted
    </Files>
    SetEnv PHPRC "C:/xampp/php7"
</Directory>
# DIRECTORIO PHP 7
<Directory "C:/xampp/htdocs/scripts7">
    UnsetEnv PHPRC
    <FilesMatch "\.php$">
        php_flag engine off
        SetHandler application/x-httpd-php7-cgi
    </FilesMatch>
</Directory>


Thanks in advance
jcadmin82
 
Posts: 1
Joined: 13. January 2023 16:19
XAMPP version: 8
Operating System: Windows and linux

Re: Multiple PHP Versions and XAMPP

Postby Altrea » 14. January 2023 15:16

Only one PHP version can be included as Apache Module.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11954
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 98 guests