WAMP PHP and where it gets php.ini

Another quickie. Evidently if you have PHP installed on your system after installing WAMP, Apache likes to go grab the php.ini file out of your main install of PHP, not the one installed with WAMP. This was causing issues in connecting to MySQL. If you get an error connecting to MySQL on a clean install of WAMP, try adding the following line to the end of the httpd.conf file that comes with WAMP:

PHPIniDir "C:/wamp/bin/php/php5.3.0"

(of course, replacing the path to the actual installation of PHP inside of WAMP)

1 thought on “WAMP PHP and where it gets php.ini”

  1. satyrwilder

    Actually, you’ll want to change the PHPIniDir throughout WAMP – WAMP builds conf and ini files dynamically, which is what causes the goofy behavior with pulling the wrong ini file.

    PHPIniDir is set in C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf and also in C:\wamp\bin\apache\Apache2.2.11\wampserver.conf. Adding PHPIniDir to the bottom of httpd.conf only overwrites the PHPIniDir set higher in the file and doesn’t affect wampserver.conf, which is set up to pull another, different php.ini.

    Just FYI, I’m only doing this because I’m trying to set up Zend on a vhost (alias) dev site with the intention of mimicking a remote hosting environment where I have one, and only one, php.ini file (custom!) Zend is easy peasy on a LAMP server that only points to one simple easy ini file, and thus to my include_path, but on WAMP, the ini weirdness has turned into a major hassle – almost more trouble than it’s worth.

Leave a Reply