In the previous post, I mentioned "attention to detail." For those of you who have served in the US military, you know this common phrase. It is taught in the most demanding ways. A smudge on a buckle or a dull spot on your shoes are both good examples. For what we are doing here, that smudge can be a typo. The dull spot can be putting one file in the wrong directory. This part is fully in the weeds so paying close attention is required.
- Read the step instructions
- Locate the needed resources including URLs, software and files
- Complete the step
- Verify the steps by walking through them a second time. I can promise you that you can save yourself hours of time and angst by catching a mistake at this point.
So, I installed XAMPP with PHP 7.4.29. You could have easily chosen to install 8.1 first. For some reason, I always seem to start low and work up. But this is documented by others to work either way. For whats if worth, I did not choose the method shown below initially as mentioned in a post a while back. lat9 metioned she had used the method below before and so far, I have found it to be a better solution. So let's get started.
- In you favorite file manager, navigate to C:/xamp
- for me, my /php folder is version 7.4.29 which is my base install. Create a new folder for the version(s) of php you want to add. Specifically, I created /php8 and /php81
- Now we need to download the correct php version from
https://windows.php.net/download#php-8.1. I used the VS16 x64 Thread Safe version for both PHP 8.0.19 and PHP 8.1.6.- Copy both files into the applicable folder that you just created. Extract both files. This zip file does not have a folder inside the zip so the files install into the chosen destination. So many times I say extract to /temp and get /temp/zipfilename instead. That is not the case here.
- There is one file missing that seems to cause problems and that is browsecap.ini. So go find this file in /php/extras and copy it into both the new folders at /php8/extras and /php81/extras.
- You will need to repeat these steps below for each php version you want to use.
- It may be that you do not have a php.ini file for this version. The instructions linked to above says to open php.ini-development and rename as php.ini. I tried that...and got a 500 server error. I used php.ini-production.
- Now open php.ini and look for
The instructions also say to uncomment if by removing the leading semicolon. Mine hadCode:extension_dir="ext"and I know that I need the php part to adjust with the version so I changed it toCode:extension_dir="C:\xampp\php\ext"
Save the php.ini file.Code:extension_dir="ext"- Launch XAMPP Control Panel as Administrator.
- Click "Configure" and you get the screen below so that we can configure Apache.
When clicking on these, Notepad will open the file for editing. Following the instructions from
https://themanish.com/run-multiple-v...ultiple-xampp/ for Steps 2 and Step 3 (we have already done Step 1 above).- Click on httpd-xampp.conf and this should open in Notepad.
- Go to the bottom on the file and add the following code for PHP 8.0. You may edit this code for other versions.
For PHP 8.1 this code has be changed so you can compare the two for other versions.Code:ScriptAlias /php8 "C:/xampp/php8" <Directory "C:/xampp/php8"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory>
Code:ScriptAlias /php81 "C:/xampp/php81" <Directory "C:/xampp/php81"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory>- So the original instructions have two options. One is folder based but the really flexible one is to create specific ports for each php version. So we are following Step 4 Option 2.
- In the same file add the following under what you just added.
for PHP 8.0
and for PHP 8.1Code:Listen 8080 <VirtualHost *:8080> UnsetEnv PHPRC <FilesMatch "\.php$"> php_flag engine off SetHandler application/x-httpd-php8 Action application/x-httpd-php8 "/php8/php-cgi.exe" </FilesMatch> </VirtualHost>
Code:Listen 8081 <VirtualHost *:8081> UnsetEnv PHPRC <FilesMatch "\.php$"> php_flag engine off SetHandler application/x-httpd-php81 Action application/x-httpd-php81 "/php81/php-cgi.exe" </FilesMatch> </VirtualHost>- Save the file.
- Restart your Apache server.
If you did everything correctly, you should be able to get the following screenshots simply by changing the port in your broswer. See examples below...
For my base install, no port is specified
for PHP 8.0, specify Port 8080 ie localhost:8080
for PHP 8.1, specify Port 8081 ie localhost:8081
This was rather long but let me know if you have any questions. We will spend some time adding xDebug to the new php versions in the next segment.
Thanks
Chris
Bookmarks