With the release of PHP 8.4, there are some new features added in, it reminds me that I may need to upgrade my development environment PHP version as well. It has php 5.x and php 7.x installed already, now I need to add php 8.x as well. This post will show the steps to achieve this.
Step 1 Install PHP 8.x
The first step is that we need to download the new PHP version. Here we chose PHP 8.1.31. Once the zip file is downloaded, unzip it and copy the folder to c:/wamp64/bin/php and rename the folder name to php8.1.31.
Step 2 Make Configuration Change
There are a few files needed to be updated: wampserver.conf, php.ini, phpForApache.ini.
wampserver.conf
This is the configuration file to tell how to find the corresponding modules for Apache. This file can be copied from other PHP folder. to php8.1.31 folder Need to add below to the copied file:
$phpConf['apache']['2.4']['LoadModuleName'] = 'php_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php8apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] = '';
Assuming you are using Apache 2.4.x. If you are using 2.2.x, please upgrade to 2.4.x first as the old version doesn't work.
php.ini
This file can be found in the same php8.1.31 folder, but its name is php.ini-development or php.ini-production, can rename php.ini-development to php.ini. Then update below entries:
extension_dir
Change it to extension_dir = "c:/wamp64/bin/php/php8.1.31/ext/"
.
track_errors
If you have this entry in php.ini(in case you copied the file from PHP 7 or earlier), please set its value to Off or remove it as this module is not supported in PHP 8.
Later please also check this same value by opening the actual php.ini being used while Apache is running. The entry in that file needs to be updated as well. Otherwise you may see below error in php error log.
[24-Nov-2024 08:08:42 UTC] PHP Fatal error: Directive 'track_errors' is no longer available in PHP in Unknown on line 0
phpForApache.ini
Change extension_dir
to extension_dir = "c:/wamp64/bin/php/php8.1.31/ext/"
.
Step 3 Change PHP Version
Now the new PHP version is not available yet but ready to use. Refresh wampserver and then can see new PHP version shown in the php version list. Select the new version, it should start normally. Can open browser and test it out.
Why go with manual installation?
Use the official WampServer installers to install the newer versions.
https://wampserver.aviatechno.net/