Using A Different Version Of PHP On A Different Port

Alles, was PHP betrifft, kann hier besprochen werden.

Using A Different Version Of PHP On A Different Port

Postby ThePie » 17. December 2020 05:43

I am trying to use a different version of PHP with XAMPP. I created a new folder in the same directory as the "php" folder called "php7325" and extracted the necessary php files to it.

When I go to http://localhost:8073/ I am getting a 500 Internal Server Error. Can someone tell me what the issue is with the config below?

I added the last two sections to the file below.
httpd-xampp.conf
Code: Select all
#
# XAMPP settings
#

<IfModule env_module>
    SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
    SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
    SetEnv PHPRC "\\xampp\\php"
    SetEnv TMP "\\xampp\\tmp"
</IfModule>

#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
LoadFile "C:/xampp/php/libsqlite3.dll"

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
#    SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>


<IfModule php7_module>
    PHPINIDir "C:/xampp/php"
</IfModule>

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

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

<Directory "C:/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/xampp/htdocs/xampp">
    <IfModule php7_module>
       <Files "status.php">
          php_admin_flag safe_mode off
       </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /licenses "C:/xampp/licenses/"
    <Directory "C:/xampp/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
   </Directory>

    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
        <IfModule php7_module>
          <Files "webalizer.php">
             php_admin_flag safe_mode off
          </Files>
        </IfModule>
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>
</IfModule>

# Custom
ScriptAlias /php7x "C:/xampp/php7325"
Action application/x-httpd-php7-cgi /php7x/php-cgi.exe
<Directory "C:/xampp/php7325">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

Listen 8073
<VirtualHost *:8073>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php7-cgi
    </FilesMatch>
</VirtualHost>
ThePie
 
Posts: 15
Joined: 23. June 2013 00:23
XAMPP version: ?
Operating System: ?

Re: Using A Different Version Of PHP On A Different Port

Postby Altrea » 17. December 2020 05:46

Apache error.log?
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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Using A Different Version Of PHP On A Different Port

Postby ThePie » 17. December 2020 06:53

Code: Select all
[Wed Dec 16 23:53:39.103345 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] malformed header from script 'php-cgi.exe': Bad header: <br />
[Wed Dec 16 23:53:39.106335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'bz2' (tried: C:\\xampp\\php\\ext\\bz2 (The specified module could not be found.), C:\\xampp\\php\\ext\\php_bz2.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.106335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:\\xampp\\php\\ext\\curl (The specified module could not be found.), C:\\xampp\\php\\ext\\php_curl.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.106335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'fileinfo' (tried: C:\\xampp\\php\\ext\\fileinfo (The specified module could not be found.), C:\\xampp\\php\\ext\\php_fileinfo.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.106335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'gd2' (tried: C:\\xampp\\php\\ext\\gd2 (The specified module could not be found.), C:\\xampp\\php\\ext\\php_gd2.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'gettext' (tried: C:\\xampp\\php\\ext\\gettext (The specified module could not be found.), C:\\xampp\\php\\ext\\php_gettext.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring' (tried: C:\\xampp\\php\\ext\\mbstring (The specified module could not be found.), C:\\xampp\\php\\ext\\php_mbstring.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'exif' (tried: C:\\xampp\\php\\ext\\exif (The specified module could not be found.), C:\\xampp\\php\\ext\\php_exif.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: C:\\xampp\\php\\ext\\mysqli (The specified module could not be found.), C:\\xampp\\php\\ext\\php_mysqli.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: C:\\xampp\\php\\ext\\pdo_mysql (The specified module could not be found.), C:\\xampp\\php\\ext\\php_pdo_mysql.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: C:\\xampp\\php\\ext\\pdo_sqlite (The specified module could not be found.), C:\\xampp\\php\\ext\\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'php_openssl.dll' (tried: C:\\xampp\\php\\ext\\php_openssl.dll (The specified module could not be found.), C:\\xampp\\php\\ext\\php_php_openssl.dll.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.107335 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  PHP Startup: Unable to load dynamic library 'php_ftp.dll' (tried: C:\\xampp\\php\\ext\\php_ftp.dll (The specified module could not be found.), C:\\xampp\\php\\ext\\php_php_ftp.dll.dll (The specified module could not be found.)) in Unknown on line 0: C:/xampp/php7325/php-cgi.exe
[Wed Dec 16 23:53:39.108346 2020] [cgi:error] [pid 19772:tid 1836] [client ::1:53287] AH01215: PHP Warning:  session_start(): Failed to read session data: user (path: C:\\xampp\\tmp) in C:\\xampp\\htdocs\\media\\libraries\\joomla\\session\\handler\\native.php on line 260: C:/xampp/php7325/php-cgi.exe
ThePie
 
Posts: 15
Joined: 23. June 2013 00:23
XAMPP version: ?
Operating System: ?

Re: Using A Different Version Of PHP On A Different Port

Postby Altrea » 17. December 2020 09:17

Seems like you did not specify the extension directory correct. php-cgi tries to load the extensions from the other php version.
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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Using A Different Version Of PHP On A Different Port

Postby Nobbie » 17. December 2020 09:58

I think its even more complicated, Windows cannot load any .DLL twice from two different locations at the same time. If you are mixing PHP module with PHP Cgi you may run in such problens, as Windows does not load a second instance of a previous loaded DLL from another location. Instead the already loaded DLL will be taken, what might fail for different PHP versions.

You have to run all PHP versions in CGI mode and anyway you have to create VirtualHosts for all of your hosts. Finally its a bad idea to use different ports for VirtualHosts, you definately should use NameBased VirtualHosts instead. And also offer proper error logs for each host.
Nobbie
 
Posts: 13165
Joined: 09. March 2008 13:04

Re: Using A Different Version Of PHP On A Different Port

Postby Altrea » 17. December 2020 16:57

Well, the german step by step tutorial i have written 6 years ago is still working (tested with XAMPP 8.0.0-2 (PHP included as Apache mod) and PHP 7.3.25 x64 TS (included by CGI).

One important part is to set the PHPRC correct so that the correct php.ini is taken.
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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Using A Different Version Of PHP On A Different Port

Postby ThePie » 17. December 2020 21:27

It would be nice if I could just swap out the php folder that is used also. I just want to use a different version of PHP but even trying to replace the existing php folder with the 7.3 folder is causing XAMPP to not start.

Is there a option in the works like WAMPP to just simple select what version of PHP you want to use?
ThePie
 
Posts: 15
Joined: 23. June 2013 00:23
XAMPP version: ?
Operating System: ?

Re: Using A Different Version Of PHP On A Different Port

Postby Altrea » 18. December 2020 00:34

ThePie wrote:Is there a option in the works like WAMPP to just simple select what version of PHP you want to use?

No
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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Using A Different Version Of PHP On A Different Port

Postby ThePie » 18. December 2020 19:00

Is there a guide that would show how to replace your version of PHP with another downloaded from https://windows.php.net/download#php-7.3 ?

Also which download should I be choosing for XAMPP on that page?
ThePie
 
Posts: 15
Joined: 23. June 2013 00:23
XAMPP version: ?
Operating System: ?

Re: Using A Different Version Of PHP On A Different Port

Postby Nobbie » 18. December 2020 20:57

ThePie wrote:Is there a guide that would show how to replace your version of PHP with another downloaded from https://windows.php.net/download#php-7.3 ?

Also which download should I be choosing for XAMPP on that page?


No, of course not. Xampp is a preconfigured distribution with certain tools. It makes the first time installation pretty easy, but it cannot be updatet. Thats the price for the easy installation. Running a webserver usually is a very sophisticated task. If you like to have more, you have to learn about Apache, PHP, MySQL etc. and how to configure these properly.
Nobbie
 
Posts: 13165
Joined: 09. March 2008 13:04

Re: Using A Different Version Of PHP On A Different Port

Postby vivekgholap » 27. July 2021 15:40

We can change the extension_dir in php.ini file of new version which we want to enable on xampp. After that just place the below code in httpd-xampp.conf file at bottom


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

<Directory "C:\xampp\htdocs\project_name">
UnsetEnv PHPRC
SetEnv PHPRC "\\xampp\\php74"
<FilesMatch "\.php$">
SetHandler application/x-httpd-php74
Action application/x-httpd-php74 "/php74/php-cgi.exe"

</FilesMatch>
</Directory>

In this example , i have wanted to enable the php 7.4 version and I already had the php 8.0 installed. Hope this helps
vivekgholap
 
Posts: 1
Joined: 27. July 2021 15:36
XAMPP version: 3.3.0
Operating System: Windows 10


Return to PHP

Who is online

Users browsing this forum: No registered users and 50 guests