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.
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 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 "C:\xampp\htdocs\my_old_project1"> <FilesMatch "\.php$"> SetHandler application/x-httpd-php56-cgi </FilesMatch> </Directory>
(For Option 2: Separate Port)
Listen 8056 <VirtualHost *:8056> <FilesMatch "\.php$"> SetHandler application/x-httpd-php56-cgi </FilesMatch> </VirtualHost>
(For Option 3: Virtualhost)
<VirtualHost localhost56:80> DocumentRoot "C:\xampp\htdocs56" ServerName localhost56 <Directory "C:\xampp\htdocs56"> Require all granted </Directory> <FilesMatch "\.php$"> 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!