Home >Backend Development >PHP Tutorial >How Can I Run Multiple PHP Versions Simultaneously with XAMPP?

How Can I Run Multiple PHP Versions Simultaneously with XAMPP?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-09 12:11:12355browse

How Can I Run Multiple PHP Versions Simultaneously with XAMPP?

Supporting Multiple PHP Versions Simultaneously in XAMPP


Running multiple PHP versions simultaneously within a single XAMPP installation addresses the need to support both legacy projects and those requiring the latest PHP features.

Four Options for Implementing PHP Version Flexibility


1. Designated Directory for Legacy PHP Version:
This approach is suitable for projects that require a specific PHP version for operation. By configuring the project directory to utilize the desired PHP version, users can isolate legacy projects from newer versions within the same XAMPP installation.

2. Separate Port for Legacy PHP Version:
This option enables testing legacy projects utilizing older PHP versions while simultaneously developing against newer PHP versions. By assigning a different port to the legacy PHP version, users can easily switch between versions without modifying project files.

3. Virtualhost for Legacy PHP Version:
Similar to option 2, using a virtualhost allows users to assign a specific PHP version to a designated virtualhost. This provides a convenient method for isolating legacy projects while accessing them through a custom URL.

4. Concurrent Support for Multiple PHP Versions:
With XAMPP, users can run multiple PHP versions simultaneously. This functionality eliminates the need to switch between versions, allowing for side-by-side development and execution of projects requiring different PHP versions.

Step-by-Step Setup Guide

Step 1: Download and Install Older PHP Version
Download the non-thread-safe (NTS) version of PHP and extract it to the desired location within your XAMPP installation, e.g., c:xamppphp56.

Step 2: Configure php.ini
Enable the extension_dir option in c:xamppphp56php.ini, and disable the PHPRC environment variable in httpd-xampp.conf.

Step 3: Configure Apache
In httpd-xampp.conf, add the following lines to configure Apache for PHP version switching:

(For Option 1: Dedicated Directory)

<Directory &quot;C:\xampp\htdocs\my_old_project1&quot;>
    <FilesMatch &quot;\.php$&quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</Directory>

(For Option 2: Separate Port)

Listen 8056
<VirtualHost *:8056>
    <FilesMatch &quot;\.php$&quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

(For Option 3: Virtualhost)

<VirtualHost localhost56:80>
    DocumentRoot &quot;C:\xampp\htdocs56&quot;
    ServerName localhost56
    <Directory &quot;C:\xampp\htdocs56&quot;>
        Require all granted    
    </Directory>
    <FilesMatch &quot;\.php$&quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

Save and restart Apache to complete the setup.

The above is the detailed content of How Can I Run Multiple PHP Versions Simultaneously with XAMPP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn