MultiPHP versions in single XAMPP Installation
Follow the below steps to add multiple versions of php in your XAMPP / WAMP etc. installation.
Step 0: Install Latest XAMPP
Step 1: Download PHP versions of your choice
Step 2: Extract to XAMPP Root (c:\xampp)
name the folder according the the version like php56, php70, php71
Step 3: Configure php.ini inside the newly created folder. If the file does not exist copy php.ini-development to php.ini, Then uncomment the following lines
extension_dir = "ext" // remove ; to uncomment
// Similarly uncomment all the extensions as per your requirements. for example
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_openssl.dll
Step 4: Configure apache
Open XAMPP control panel, click config button for apache, and click Apache (httpd-xampp.conf). A text file will open up put the following settings at the bottom of the file:
ScriptAlias /php56 "C:/xampp/php56"
Action application/x-httpd-php56-cgi /php56/php-cgi.exe
<Directory "C:/xampp/php56">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
SetEnv PHPRC "C:/xampp/php56"
</Directory>
The above code to be adjusted based on the version of PHP selected. like for PHP 7.0 replace php56 with php70.
Congratulations now you are all set to use the installed versions of PHP on your sites. You can use the particular version by creating a virtual host for each website and telling the apache to use a particular version by setting an appropriate handler as shown below. Open the xampp\apache\conf\extra\httpd-vhosts.conf and use the below code for each website with appropriate handlers based on the above config in step 4. DocumentRoot must be set to the location where your project files are present.
<VirtualHost *: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>
Note: Dont forget to uncomment the NameVirtualHost *:80 to enable virtual hosts.
Awsome Stuff Prof.
ReplyDelete