How to manually Install php on WampServer.

I especially like that WampServer allows you to have multiple versions of php (and MySQL and Apache) installed. You can switch between versions in the WampServer menu on the icon in the system tray.

The server that an upcoming client project will be hosted on will be running php version 5.2.14. That version isn’t available for download on the WampServer website, but that doesn’t mean that I’m out of luck. I decided to manually install php to see if I could get it running, and I succeeded.  I wanted to share my process so that you can do it to (and so that I know what I need to do if I have to install another version that isn’t available on WampServer).

Download the php windows binaries

There are 2 sources for the binaries, and I recommend downloading the files from because they are more up-to-date. I ran into an issue where the cURL extension wouldn’t load. It turns out the php team made some changes to the php_curl.dll file to correct those issues. The download on doesn’t include those changes (it’s an older version).

No matter which source you choose to download the binaries from, download the zip package. Extract the contents of the zip file to C:/wamp/bin/php/php5.2.14 (change the path to reflect where you have WampServer installed and the version number to whatever version you are installing).

Modify the php.ini file

You need to make some changes to the php.ini file in order for it to work with WampServer. NOTE: You will need to modify the paths to reflect where your installation of WampServer is (mine is in C:/wamp). You will also have to modify the extension_dir if you are installing a version other than 5.2.14. The following lines indicate the changes you will need to make. Just do a search to find where in the file the lines are so you can make the changes (I noticed that the line numbers vary between php versions, so I didn’t include them here).

[sourcecode language=”php”]
; Log errors to specified file.
error_log = c:/wamp/logs/php_error.log
; Directory in which the loadable extensions (modules) reside.
extension_dir = "c:/wamp/bin/php/php5.2.14/ext/"
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "c:/wamp/tmp"
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process’s umask.
session.save_path = "c:/wamp/tmp"

You will also want to enable/disable any extensions that you need for your application(s).

Once you have completed your changes to the php.ini file, you will need to save a copy of the file with the filename of phpForApache.ini (in the same directory as the php.ini file). You must do this in order for WampServer to use the new version. WampServer copies this file to the Apache server when you select the version from the menu.

Modify the WampServer configuration

If you already have WampServer running with another version of php, copy the wampserver.conf file from that version into your newly installed version. If you don’t have another version running, paste the following code into a file and save it in the directory that you extracted the php files to.

[sourcecode language=”php”]
$phpConf[‘phpIniDir’] = ‘.’;
$phpConf[‘phpExeDir’] = ‘.’;
$phpConf[‘phpConfFile’] = ‘php.ini’;
$phpConf[‘apache’][‘1.3’][‘LoadModuleName’] = ‘php5_module’;
$phpConf[‘apache’][‘1.3’][‘LoadModuleFile’] = ‘php5apache.dll’;
$phpConf[‘apache’][‘1.3’][‘AddModule’] =  ‘mod_php5.c’;
$phpConf[‘apache’][‘2.0’][‘LoadModuleName’] = ‘php5_module’;
$phpConf[‘apache’][‘2.0’][‘LoadModuleFile’] = ‘php5apache2.dll’;
$phpConf[‘apache’][‘2.0’][‘AddModule’] =  ”;
$phpConf[‘apache’][‘2.2’][‘LoadModuleName’] = ‘php5_module’;
$phpConf[‘apache’][‘2.2’][‘LoadModuleFile’] = ‘php5apache2_2.dll’;
$phpConf[‘apache’][‘2.2’][‘AddModule’] =  ”;

You will also need to make some changes to the C:/wamp/wampmanager.ini file so that you will be able to switch to the version you are installing.

In the [phpVersion] section (line 335) add the following (change the version number to reflect your version):

[sourcecode language=”php”]
Type: item; Caption: "5.2.14"; Action: multi; Actions:switchPhp5.2.14

At the end of the section (before ;WAMPPHPVERSIONEND), add the following code (again, change the version number to reflect your version):

[sourcecode language=”php”]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "c:/wamp/bin/php/php5.3.0/php-win.exe";Parameters: "switchPhpVersion.php 5.2.14";WorkingDir: "c:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "c:/wamp/bin/php/php5.3.0/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "c:/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;

Restart the server and verify

After you have made and saved these changes, exit out of WampServer and restart it. Once it is back up and running, switch to your newly installed version of php. You can do this in the menu (see screenshot). Your final step should be to set up a phpinfo page and verify that the newly installed version of php is running and has all of the extensions enabled that you need.

That’s it. It’s as simple as that (I did all the hard work for you). You can now start developing your php application.

Leave a Comment

Your email address will not be published. Required fields are marked *