How to install PHP 8 in Wampserver and have it run side by side
Posted by: robotdan (---.skybroadband.com)
Date: July 07, 2020 02:09AM

NO LONGER REQUIRED
WAMPServer now supports PHP 8 and has since the day PHP8 was Officially Released

Simply download the required PHP8 ADDON from SourceForge or the backup repo which is easier to navigate
Or any other PHP/Apache/MySQL/mariaDB version you want


In this topic I'll explain how to get PHP 8 working within Wampserver and be able to switch between it and other versions of PHP.

EDIT: Fixed instructions for Wampserver 3.2.2.
EDIT2: Added missing extensions reported by Wampserver to phpForApache.ini.
EDIT3: The wampserver.lib.php script file does need to be edited for Wampserver 3.2.2 otherwise module loading breaks when switching to other PHP versions. Sorry, I should have caught this. Also fixed intl not loading and the missing php.ini file needed for CLI mode. Thanks to Otomatic for pointing it out.

Disclaimer: Wampserver does not officially support PHP 8 yet, so do this at your own risk. This guide is written for PHP 8.0.0 alpha 1. Things may change for newer preview releases, though I'm not expecting it to between now and the stable release. This is also for advanced users. If you don't know what you are doing, you may hose your Wampserver installation. If you have any doubts, I'd advise you to wait until PHP 8 stable when there should be an official Wampserver installer for it.

Pre-requisites: You need the latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019, which you can find on this page. Install the one applicable to your Wampserver installation.

You also need to update Wampserver to 3.2.2 which is the current latest version. This guide will not work for older versions. You can find the update here for the 64-bit version.

Next you need to download the PHP 8.0.0 alpha 1 zip. You can find Windows binaries for preview PHP versions on this page. I normally recommend getting the thread safe version, but again pick the one that's applicable.

Once downloaded, navigate to your Wampserver folder and then go to bin\php, then create a new folder within called php8.0.0alpha1. For default 64-bit Wampserver installations this will be located at C:\wamp64\bin\php. Open the zip archive you've just downloaded and extract the contents to this new folder.

Normally if you're manually installing a new version of PHP this way, you can copy wampserver.conf and create a new phpForApache.ini file, then refresh Wampserver and call it a day. However, PHP 8 will not work out of the box by doing this and there a few extra steps that need to be done first.

Instead, you should create a new wampserver.conf file inside the php8.0.0alpha1 folder and paste the contents from below:
<?php

$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';

//PHP 8 needs Apache 2.4.x and doesn't works with Apache 2.2.x
//and php_module, not php7_module or php5_module
$phpConf['apache']['2.4']['LoadModuleName'] = 'php_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php8apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] =  '';

?>
The difference is that PHP 8 has renamed php7_module to php_module and php7apache2_4.dll is now php8apache2_4.dll.

Next you should copy php.ini-development and rename the copy to phpForApache.ini. This is so that you have a fresh config file as a template. It will need changing in a few places in order to point to the correct folders. Look for the following lines and make these changes so that PHP 8 understands the Wampserver folder hierarchy. I'm using the paths for the default 64-bit Wampserver installation, so change these to wherever you have it installed.
error_log ="c:/wamp64/logs/php_error.log"
extension_dir ="c:/wamp64/bin/php/php8.0.0alpha1/ext/"
upload_tmp_dir ="c:/wamp64/tmp"
sendmail_from ="admin@wampserver.invalid"
session.save_path ="c:/wamp64/tmp"
soap.wsdl_cache_dir="c:/wamp64/tmp"
[opcache]
zend_extension="c:/wamp64/bin/php/php8.0.0alpha1/ext/php_opcache.dll"
You probably want to enable the same extensions as you did with PHP 7.x as well. This is how I have it set up.
extension=bz2
extension=curl
extension=com_dotnet
;extension=dba
;extension=enchant
;extension=ffi
;extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=phpdbg_webhelper
;extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See [www.php.net]
;extension=snmp

extension=soap
extension=sockets
;extension=sodium
extension=sqlite3
;extension=sysvshm
;extension=tidy
extension=xsl
;extension=zend_test

;zend_extension=opcache
You can configure the rest of the file as you see fit. I normally set these variables just for QoL.
max_execution_time = 120
post_max_size = 32M
upload_max_filesize = 32M
If you want CLI mode to work as well, then you also need to create a php.ini file for it. You can get away with just copying the contents of phpForApache.ini into it.

With that, PHP 8 is configured but it will still not work properly with Wampserver out of the box. Do not switch Wampserver to PHP 8 just yet, as you may not be able to switch back. To fix this, you will need to edit a couple of scripts in order to get them compatible.

Go to the root folder where Wampserver is installed (C:\wamp64 for default 64-bit installations). I recommend backing up the scripts folder within here in case you need to revert as a couple of scripts inside need to be changed. Bear in mind that you're going to be hacking these script files, so if you mess up it could cause Wampserver to stop functioning properly. Be sure you know how to recover in the event of this breaking something before you proceed. Also note that Wampserver updates may overwrite the scripts you will be modifying.

Navigate to the scripts folder.

The main file that needs to be changed is wampserver.lib.php. You need to look for the following line (line 268 for me, but it may be different for you).
	$search = '~^(LoadModule[ \t]+)(php7_module|php5_module)([ \t]+".+/bin/php/)(.+)(/)(.+\.dll)"\r?$~mi';
Change this to the following:
	$search = '~^(LoadModule[ \t]+)(php_module|php7_module|php5_module)([ \t]+".+/bin/php/)(.+)(/)(.+\.dll)"\r?$~mi';
Now you'll be able to switch between PHP 8 and other versions within Wampserver without the modules failing to load.

For good measure, there's one more script left to edit. Open config.inc.php and look for these lines:
//dll to create symbolic links from php to apache/bin
//Versions of ICU are 38, 40, 42, 44, 46, 48 to 57, 60 (PHP 7.2), 61 (PHP 7.2.5)
//  62 (PHP 7.2.8), 63 (PHP 7.2.12), 64 (PHP 7.2.20), 65 (PHP 7.4.0), 66 (PHP 7.4.6)
$icu = array(
	'number' => array('66', '65','64', '63', '62', '61', '60', '57', '56', '55', '54', '53', '52', '51', '50', '49', '48', '46', '44', '42', '40', '38'),
	'name' => array('icudt', 'icuin', 'icuio', 'icule', 'iculx', 'icutest', 'icutu', 'icuuc'),
	);
This needs '67' adding to the array so that PHP 8 can load the intl extension.
//dll to create symbolic links from php to apache/bin
//Versions of ICU are 38, 40, 42, 44, 46, 48 to 57, 60 (PHP 7.2), 61 (PHP 7.2.5)
//  62 (PHP 7.2.8), 63 (PHP 7.2.12), 64 (PHP 7.2.20), 65 (PHP 7.4.0), 66 (PHP 7.4.6), 67 (PHP 8.0.0)
$icu = array(
	'number' => array('67', '66', '65','64', '63', '62', '61', '60', '57', '56', '55', '54', '53', '52', '51', '50', '49', '48', '46', '44', '42', '40', '38'),
	'name' => array('icudt', 'icuin', 'icuio', 'icule', 'iculx', 'icutest', 'icutu', 'icuuc'),
	);
Just below that there's another array that needs adding to.
$phpDllToCopy = array_merge(
	$php_icu_dll,
	array (
	'libmysql.dll',
	'libeay32.dll',
	'ssleay32.dll',
	'libsasl.dll',
	'libpq.dll',
	'libssh2.dll', //For php 5.5.17
	'libsodium.dll', //For php 7.2.0

	'libsqlite3.dll', //For php 7.4.0

	'php5isapi.dll',
	'php5nsapi.dll',
	'php5ts.dll',
	'php7ts.dll', //For PHP 7
	)
);
This needs php8ts.dll adding to the end of the array like this:
$phpDllToCopy = array_merge(
	$php_icu_dll,
	array (
	'libmysql.dll',
	'libeay32.dll',
	'ssleay32.dll',
	'libsasl.dll',
	'libpq.dll',
	'libssh2.dll', //For php 5.5.17
	'libsodium.dll', //For php 7.2.0

	'libsqlite3.dll', //For php 7.4.0

	'php5isapi.dll',
	'php5nsapi.dll',
	'php5ts.dll',
	'php7ts.dll', //For PHP 7
	'php8ts.dll', //For PHP 8
	)
);
Then finally at the end of the same file, there's another line that needs changing.
// Apache modules which should not be disabled
$apacheModNotDisable = array(
	'authz_core_module',
	'authz_host_module',
	'php5_module',
	'php7_module',
	);
This just needs php_module adding to the end of the array like this:
// Apache modules which should not be disabled
$apacheModNotDisable = array(
	'authz_core_module',
	'authz_host_module',
	'php5_module',
	'php7_module',
	'php_module',
	);
And that should be it. Right click Wampserver in the system tray and select Refresh. It should pick up PHP 8. Then you should be able to switch to and from it just like any other version of PHP.

One note is that JIT compilation is turned on by default within the php.ini file so you should see a decent performance improvement over PHP 7.4.

This guide should work for newer preview releases of PHP 8. They just need the paths changing to reflect that version.

Happy testing! smiling smiley



Edited 4 time(s). Last edit at 02/16/2021 04:44PM by RiggsFolly.

Options: ReplyQuote
Re: How to install PHP 8 in Wampserver and have it run side by side
Posted by: Otomatic (Moderator)
Date: July 07, 2020 10:10AM

Hi,

Bravo! You have understood well how the change of PHP version in Wampserver works.*

Wampserver update 3.2.3 will be ready for PHP 8, but will only be released when the stable PHP 8.0.0 version is released, as there might be some other code changes needed.

* There are just two little omissions:
- PHP 8 uses icu version 67 so, in config.inc.php
Replace :
//Versions of ICU are 38, 40, 42, 44, 46, 48 to 57, 60 (PHP 7.2), 61 (PHP 7.2.5)
//  62 (PHP 7.2.8), 63 (PHP 7.2.12), 64 (PHP 7.2.20), 65 (PHP 7.4.0), 66 (PHP 7.4.6)
$icu = array(
	'number' => array('66', '65','64', '63', '62', '61', '60', '57', '56', '55', '54', '53', '52', '51', '50', '49', '48', '46', '44', '42', '40', '38'),
by :
//Versions of ICU are 38, 40, 42, 44, 46, 48 to 57, 60 (PHP 7.2), 61 (PHP 7.2.5)
//  62 (PHP 7.2.8), 63 (PHP 7.2.12), 64 (PHP 7.2.20), 65 (PHP 7.4.0), 66 (PHP 7.4.6), 67 (PHP 8.0.0)
$icu = array(
	'number' => array('67', '66', '65','64', '63', '62', '61', '60', '57', '56', '55', '54', '53', '52', '51', '50', '49', '48', '46', '44', '42', '40', '38'),

- You also need a php.ini file in addition to the phpForApache.ini file to support PHP 8 in CLI mode.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: How to install PHP 8 in Wampserver and have it run side by side
Posted by: robotdan (---.skybroadband.com)
Date: July 07, 2020 05:57PM

Whoops, I missed the ICU version change. I've added that to the OP. I've also added the missing php.ini file to the guide. Thanks for noticing this.

I had also made another mistake which I've fixed. I initially tested with Wampserver 3.2.0 and just assumed it was the latest version. Then I double checked and found out at the last minute it wasn't and quickly retested with 3.2.2. It looked OK at a glance but I foolishly didn't check my PHP error log and only now realised I've broken module loading. To fix it, wampserver.lib.php needs a line changed as well. Sorry, my bad.

Options: ReplyQuote
Re: How to install PHP 8 in Wampserver and have it run side by side
Posted by: Otomatic (Moderator)
Date: July 07, 2020 07:39PM

Hi,

> I foolishly didn't check my PHP error log
php_error.log is what I call in French "le juge de paix"* to check for possible errors when switching versions. This file is always part of my "projects" in Ultraedit.
The second "justice of the peace", concerning version failover, is the localhost page which must not have an error at the bottom of the page.

* A somewhat untranslatable expression, the "justice of the peace" was, in ancient times, the first level of justice and consultation.
Justices of the peace were local courts, set up in France in 1790 and abolished in 1958. At that time, there was one per canton.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: How to install PHP 8 in Wampserver and have it run side by side
Posted by: synx (---.w90-2.abo.wanadoo.fr)
Date: January 25, 2021 10:58AM

in wampserver.lib.php for php 8.0.1

change in line : 272
// $php8v = $phpConf['apache'][$apacheVersion]['LoadModuleName'];
$newline = 'LoadModule '. ($php8v == 'php8_module' ? 'php_module' : $php8v )...
// because créate in httpd.conf LoadModule php8_module "${INSTALL_DIR}/bin/php/php8.0.1/php8apache2_4.dll"
// or is not php8_module, is php_module



if (strpos($line,'LoadModule') !== false && (strpos($line,'php_module') !== false || strpos($line,'php5_module') !== false || strpos($line,'php7_module') !== false))
{
$c_phpVersionDirA = (substr($c_apacheVersion,0,3) == '2.4') ? str_replace($c_installDir, '${INSTALL_DIR}',$c_phpVersionDir) : $c_phpVersionDir ;
$php8v = $phpConf['apache'][$apacheVersion]['LoadModuleName'];
$newline = 'LoadModule '. ($php8v == 'php8_module' ? 'php_module' : $php8v ). ' "'.$c_phpVersionDirA.'/php' . $newPhpVersion . '/'.$phpConf['apache'][$apacheVersion]['LoadModuleFile'].'"'."\r\n";
if($line !== $newline) {
$newHttpdContents .= $newline;
$change = true;
}
}



Edited 4 time(s). Last edit at 01/25/2021 11:09AM by synx.

Options: ReplyQuote
Re: How to install PHP 8 in Wampserver and have it run side by side
Posted by: Otomatic (Moderator)
Date: January 25, 2021 12:25PM

@ synx

Bonjour,

Il n'y a absolument pas besoin de vos modifications à la con pour faire tourner PHP 8.0.1 avec Wampserver.

Il suffit simplement d'appliquer la mise à jour Wampserver 3.2.4 comme cela est indiqué si vous essayer d'installer l'addon PHP 8.0.1 sur un Wampserver de version inférieure à 3.2.4.

Depuis fin 2014 et Wampserver 3, il n'y a jamais eu besoin de modifier manuellement les scripts PHP pour installer un addon de version PHP.

Les versions PHP 8.0.x sont supportées depuis Wampserver 3.2.4.

Vous auriez été bien avisé de ne pas vous inscrire sur ce forum uniquement pour venir y raconter des conneries et tenter d'induire en erreur les utilisateurs de Wampserver.

Hello,

There is absolutely no need for your stupid modifications to run PHP 8.0.1 with Wampserver.

Just apply the Wampserver 3.2.4 update as indicated if you try to install the PHP 8.0.1 addon on a Wampserver with a version lower than 3.2.4.

Since the end of 2014 and Wampserver 3, there has never been a need to manually modify PHP scripts to install a PHP version addon.

PHP 8.0.x versions are supported since Wampserver 3.2.4.

You would have been well advised not to register on this forum just to come and tell bullshit and try to mislead Wampserver users.

I first wrote in French because synx connects from wanadoo.fr which is a French ISP.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 01/25/2021 02:28PM by Otomatic.

Options: ReplyQuote


Sorry, only registered users may post in this forum.