Using Multiple PHP Versions in XAMPP
Introduction
XAMPP is a popular web development tool that includes Apache, MySQL, and PHP. By default, XAMPP comes with a single PHP version. However, there may be situations where you need to use multiple PHP versions, such as for running legacy projects that still rely on older PHP functions.
Options for Using Multiple PHP Versions
There are several ways to use multiple PHP versions in XAMPP:
Option 1: Specify PHP Version for Specific Directories
This option allows you to configure specific directories to run with a particular PHP version. To do this:
ScriptAlias /php56 "C:/xampp/php56" Action application/x-httpd-php56-cgi /php56/php-cgi.exe
<Directory "C:\xampp\htdocs\my_old_project1"> <FilesMatch "\.php$"> SetHandler application/x-httpd-php56-cgi </FilesMatch> </Directory>
Option 2: Run an Older PHP Version on a Separate Port
This option allows you to run an older PHP version on a different port than XAMPP's default. To do this:
Listen 8056 <VirtualHost *:8056> <FilesMatch "\.php$"> SetHandler application/x-httpd-php56-cgi </FilesMatch> </VirtualHost>
When you access a PHP file on port 8056 (e.g., http://localhost:8056/old_project.php), it will run with the older PHP version.
Option 3: Run an Older PHP Version on a Virtualhost
This option allows you to create a virtualhost that uses a specific PHP version. To do this:
<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>
When you access a PHP file on the virtualhost (e.g., http://localhost56/old_project.php), it will run with the older PHP version.
The above is the detailed content of How Can I Use Multiple PHP Versions Simultaneously with XAMPP?. For more information, please follow other related articles on the PHP Chinese website!