0

I have php 7.4 by default in my xampp (in the path c:\xampp\php) and my most projects are running on it.Now, I've a php 8 project & so need to run xampp with php 8.1 on a different port(8056).I tried doing it with the answer mentioned in this link:

How to use Multiple xampp Like xampp php version 5, xampp php version 7, version 8. I also install it but problem new laravel project npm not install

Although the new port (8056) is also getting listed under ports in Xampp control panel, not able to load xampp with it.When running http://localhost:8056/ , am getting the error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/7.4.27 Server at localhost Port 8056

In the last line of this error,it seems it is still running on php.7.4 . I wanted only php 8.1 to listen on this port. How can I fix this? Any help is much appreciated.

Steps I did:

1.downloaded php 8(non thread safe version) & extracted file to the path c:\xampp\php8

2.As the php.ini file does not exists in the path c:\xampp\php8, created a new text file & named it php.ini.Copied the contents in php.ini-development to php.ini and uncommented the line

extension_dir = "ext"

3.Added content mentioned in step 3 & step 4- option 2 with only modifications for the php version name as below.Below given is the full content of my current xampp - Apache config file (httpd-xampp.conf)

#
# 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"
LoadFile "C:/xampp/php/libsqlite3.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.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>

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

Listen 8056
<VirtualHost *:8056>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php8-cgi
    </FilesMatch>
</VirtualHost>
  1. saved its contents & restarted xampp & apache.
m ge
  • 1
  • 2
  • I'm sorry. I cannot follow your code. Apparently you use Larael. Isn't Lavarel supposed to make everything like this a piece of cake? They imply it does. – Misunderstood Oct 28 '22 at 07:53
  • @Misunderstood Yes.I use laravel. I don't know how laravel does it.My ultimate need is just to run xamp with php 8 in a different port by keeping php 7 also on default port. – m ge Oct 28 '22 at 08:06
  • You can look into Laravel Sail. It makes it super easy to use different environments, such as changing PHP version, MySQL version and so on. It uses Docker. You can read more about it here https://laravel.com/docs/9.x/sail#main-content – Kipras Bielinskas Oct 28 '22 at 08:14

3 Answers3

1

Every step you take is correct but you just missed only one step.

Open the file (httpd-xampp.conf) and comment out line 10 by just preceding it with # so instead of SetEnv PHPRC "\\xampp\\php" you should have # SetEnv PHPRC "\\xampp\\php"

if you do it correctly, the first 11 lines should look like this

#
# 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>

Now everything should work fine.

0

I used XAMPP and had ran into the same issue. I have since moved to Laragon and it makes using different versions of PHP & MySQL simple.

Check it out: Laragon

Ray C
  • 164
  • 8
  • I wanted to use it on Xampp – m ge Oct 28 '22 at 08:09
  • I understand. Wanted to show you an option to make your life easier. With Laragon you can switch between version with a single click. I cannot be much help with Xampp, hope you can find someone that can. – Ray C Oct 28 '22 at 08:12
0

i agree laragon is best for windows not sure if you can use multiple php on xamp without installing it in different folders

maybe this works

Is there way to use two PHP versions in XAMPP?

  • this is the same thing I have tried. check the link i mentioned in orginal question. – m ge Oct 28 '22 at 09:22