How to configure PHP 7 on WAMP server in localhost

Being a PHP developer you want to configure PHP 7 on your localhost for various reasons. You might want to explore the new features of PHP 7 or you might be upgrading your existing website to PHP 7 and want to test in your local machine first or you might be creating a brand new project on PHP 7. This blog will help you to configure PHP 7 for WAMP server in localhost.

(Note: You first check with your hosting server about PHP 7 is available or not. If yes, what version of PHP 7 is available.)

Very first thing to know is PHP 7 requires minimum Apache 2.4.x and also it needs WAMP Server 2.5. If you already have WAMP 2.5, ou do not have to uninstall anything. You can configure PHP 7 with WAMP 2.5. How to check your WAMP server version? Right click on the WAMP icon on your windows taskbar and click About... It will show your current WAMP version.

Download the required PHP version (thread safe version) depending on your 32 or 64 bit Windows from here http://windows.php.net/qa. As of now PHP 7.1.7 is available so I have downloaded PHP 7.1(7.1.7 RC1).

Now you need to download and install Microsoft Visual C++ Redistributable for Visual Studio 2015 (Click here). This is needed for WAMP to work properly. If you are using 32 bit OS, then download 32 bit package only. If you have 64 bit OS, then I recommend to install both 32-bit as well as 64-bit packages.

Once all this done, then we are ready to install/configure PHP 7 in local machine.

Let’s start installing PHP 7:

Step 1: Locate to your WAMP directory, (usually C:/wamp). Goto C:/wamp/bin/php and create a new folder “php7.1.7″ and extract the content of PHP 7.1.7 RC1 Thread Safe version here.

Step 2: Now, navigate to your old php folder. (mine is php5.5.12), and copy wampserver.conf from old and paste it to your “php7.1.7″ folder

Step 3: Now, go to C:/wamp/bin/php/php7.1.7 folder and locate file php.ini-development. Copy it and rename to php.ini in the same directory.

Open php.in file and update the following values:

  1. extension_dir = C:/wamp/bin/php/php7.1.7/ext
  2. upload_tmp_dir = C:/wamp/tmp
  3. error_log = C:/wamp/tmp

 Now, scroll down to extension list replace them with the below text:

extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_gmp.dll
extension=php_intl.dll
extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll

extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll

Save and close the file.

Step 4: Now, make a duplicate of php.ini file and save it as phpForApache.ini. This file is needed by Apache web server.

Step 5: Now open wampserver.conf copied in C:/wamp/bin/php/php7.1.7/ directory in Step 2 above. It should look like below:

<?php

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

$phpConf['apache']['2.2']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.2']['LoadModuleFile'] = 'php5apache2_2.dll';
$phpConf['apache']['2.2']['AddModule'] =  '';

$phpConf['apache']['2.4']['LoadModuleName'] = 'php7_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php7apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] =  '';

?>

 

Step 6: Start WAMP server and goto PHP >> PHP Version and there you must find version 7.1.7 and select it.

Step 7: Create a test php file in www directory of WAMP installation path. Put the below code:

<?php
   phpinfo();
?>

You will find that the version of php is 7.1.1 and all other details of extensions.

Final suggestion: It is better to include the new path in your system path directory otherwise you may face some issues with you CURL extension. Go to Windows environment variable window and edit system variable "Path" to add a new string "C:\wamp\bin\php\php7.1.7;". This step will resolve the CURL error "Unable to load dynamic library 'php_curl.dll' - The specified module could not be found in Unknown on line 0"

Wish you happy coding with PHP 7. Watch the YouTube video for quick reference:

Comments