> the protogenLabs notebook » reading full entry…


Fixing a php.ini configuration file problem

» posted 4452 days ago @ 07:41 PM by George Merlocco in web

Though not too many people run PHP on top of IIS, (it's usually Apache, or LAMP) I am one of the few who does. I recently underwent setting up a proper development environment. This of course included installing PHP 5 and MySQL 5 onto IIS7 (within Windows Web Server 2008). I followed this guide which resulted in a successful integration of PHP within IIS7. Also note that if you are installing PHP onto Windows Server 2008 or IIS7, do NOT use the "Windows Installer" to set it up. Instead, grab the .zip file of all PHP files, and run through the manual installation procedures.

Anyways, on to the actual issue that I was experiencing, which caused me to reinstall Windows and waste about 5 hours of my precious life ;) I had PHP working, but the MySQL extension was not being loaded, specifically "php_mysql.dll". I thought everything was fine and dandy because when I ran a simple PHP_info test page that contained:

< ?php phpInfo();? >

I was greeted with the PHP configuration settings, however what I had failed to notice the first time was that some variables were not set correctly:

Configuration File (php.ini) Path = C:\Windows
Loaded Configuration File = (none)

It had seemed that even though I had added "C:\PHP" to my Windows Server 2008 System Variables in the PATH section, PHP was still not seeing my php.ini file which was really in C:\PHP. There was NO php.ini file in C:\Windows either. After wrestling with this for hours, I gave in and tried putting php.ini in C:\Windows, as well as having it in C:\PHP. For some unknown reason, PHP finally began to work, and I saw my php_mysql.dll file being loaded successfully. I know that this is NOT the preferred way, as you really want to keep all of your PHP files contained to the one directory, but there just wasn't a way to get this working without tearing ALL of my hair out.

If you wanted to follow up on the issue to see if the PHP team has fixed this bug, keep an eye on the official bug page. I hope this helps anyone who's run into this issue. If you have, please post your experience below, and let us know if there's anything else you've done to fix it!

comments 24 comments submitted  article's permanent link permalink  hop to the top^ back to top
article tags article tags: , , ,   Bookmark and Share

> Leave a comment? [24] article comments…


Server 2008 has same problem

by Mike on 02.12.2010 @ 02:49 AM » #


I installed php with ISAPI in Windows Server 2008.
It went so bad that there was 404 error if the PATH was set in Environmental Variables. PHP worked fine when C:\PHP was removed from the PATH variable.

I put php.ini in C:\windows and it worked well. But still I can’t change the “Configuration File (php.ini) Path”

by d_shre on 02.12.2010 @ 02:50 AM » #


Hmm same problem here but with Windows 7, can’t load the extension=php_mysql.dll because the php.ini file is not being read for some reason.

Tried copying it to C:\windows as well as c:\php and no luck :(

any ideas?

by zag on 02.12.2010 @ 02:51 AM » #


Hi guys,
Thanks to the advice above, I could get my sql extension running. When you copy the php.ini file in the windows folder, make sure that the php.ini file still links to the correct extension path (in my case the absolute path is ( extension_dir = “C:\PHP\ext”)

by coco on 03.06.2010 @ 06:06 PM » #


Thanks. Couldn’t help but leave a comment. Solution worked for me. I’m not so familiar with the setup with IIS but I’ve been doing PHP for years now. :) Cheers!

by clemton on 05.07.2010 @ 09:56 AM » #


hi i had same problem on winXP but no IIS running i think.. i copied php.ini to c:\windows and changed extension_dir path and after several apache restarts settings took and it started to work :p

by commentzor on 09.06.2010 @ 10:07 AM » #


Thanks! After looking for most of the day to troubleshoot this, I finally found this post. Even theough I copied it over to the Windows dir though, it still would not load the ini. Figured that restarting the web service from the IIS6 GUI was not doing a complete restart of the services so I finally did an IISRestart from the command prompt and voila! It sees the windows dir one but still not the one in the PHP folder…oh well at least it’s working!

by cmmitw on 11.18.2010 @ 04:38 PM » #


i had the same problem with windows 7 so i edited Apache configuration as following.

changed php dir with httpd slash ( / ) and it worked well !

PHPIniDir “C:/Program Files/php/”

hope that works well with you

by Abdullah Maswadeh on 08.28.2011 @ 04:08 PM » #


Having same problem with windows XP. using PHP Version 5.3.8….my php ini file was showing the icon of a text file, Then i come to know that it was php.ini.txt.. i renamed it with “ “ …. like “php.ini” selecting type as all files. then restarting my apache i saw the correct loaded path c:/php/php.ini…..cheers :-)

by Danyal on 08.28.2011 @ 04:44 PM » #


I have been pulling my hair out trying to get this to work. Finally someone posted the answer! I did have to reboot the server after copying the php.ini file to c:\windows, but it worked! Thanks for the post.

by SueB on 10.12.2011 @ 11:21 AM » #


I had the problem under Windows 7. It would actually find the correct php.ini when run as php.exe -i, but not using phpinfo (); through apache.

I changed PHPIniDir to use / instead of \ as suggested above and it started working.

by Doug Porter on 01.23.2012 @ 02:21 PM » #


chequea esta variable en el httpd.conf
PHPIniDir ‘c:/windows’ dentro de ese directorio debe estar el php.ini

by luis on 05.16.2012 @ 07:46 PM » #


It’s strange, but this worked for me:
in my apache httpd.conf on the line PHPIniDir change the slashes from \ to / and make sure it points to the folder with your ini file. System: Windows 7.

by nads on 05.20.2012 @ 05:07 PM » #


“I had the problem under Windows 7. It would actually find the correct php.ini when run as php.exe -i, but not using phpinfo (); through apache.

I changed PHPIniDir to use / instead of \ as suggested above and it started working.”

This works well… No need to move php.ini to C:\WINDOWS thanks for this post :)

by Sonia on 08.14.2012 @ 05:17 AM » #


Encountered the same problem. In my case, there were some dlls mentioned in php.ini were not getting loaded properly. I did a “php -m” at the command prompt in the php folder. Corrected the errors (basically commented the dlls that were not required). PHPIniDir was set using double quotes and forward slashes. Then it worked – phpinfo() showed the loaded configuation file and it recognized mysqli calls.

by Kothai on 09.04.2012 @ 01:05 AM » #


Apache/2.2.11 (Win32)
MySQL Server 5.0.77
phpMyAdmin – Version 4.0.5
Windows XP Prof.

I have the same problem with loading modules mbstring, mysql and mysqli. Phpinfo() doesn’t show this modules, and any other information about it. I use the information given by Sonia on 08.14.2012 @ 05:17 AM and in command winndow (cmd) I wrote ‘php -i -> phpinfo.txt’. So I had all ifo in file. In this file I have info about mbstrig, mysql etc , but NOT using phpinfo(). I had try using double quotes and forward slashes but it didn’t work; moveing php.ini to C:\WINDOWS too. I still didn’t find the solurion.

by Andrew on 08.30.2013 @ 05:47 PM » #


I compare the files phpinfo.txt and a webpage generated from function phpinfo(). Problem was with “Loaded Configuration File”. In phpinfo.txt it was C:\PHP\php.ini and on webpage was (none).
In my PHP code I useed “<?” then “<?php”. Some pages are wrong interpreted. You should use “<?php ….. ?>”.

by Andrew on 09.02.2013 @ 11:48 AM » #


(I know it’s an old post, but anyway…)

To solve the issue, in the httpd.conf you just need to use slashes “/” instead of backslashes “\” in your paths for PHPIniDir and LoadModule.

by AlainD. on 10.20.2014 @ 03:02 AM » #


Try to copy php.ini to apache/bin dir

by yikai.shao on 12.10.2014 @ 08:36 PM » #


look, I had the same problem…all the answers above help’s to make that configuration to work. Do this: Inside httpd Apache Server httpd.conf digit the following PHPIniDir “C:/PHP/php.ini-development”

by gabromye on 05.21.2015 @ 12:30 AM » #


I didn’t have the same but your informal solution helped me to fix my issue. I had misspelled php.ini.

thanks for sharing,

by Antonis Flangofas on 12.09.2015 @ 02:48 AM » #


thnx! thats worked for me!
look, I had the same problem…all the answers above help’s to make that configuration to work. Do this: Inside httpd Apache Server httpd.conf digit the following PHPIniDir “C:/PHP/php.ini-development”

by alex on 05.06.2016 @ 06:54 AM » #


This is a really good site post, i am delighted I came across it. I will be back down the track to check out other posts that..

by Linda Nash on 05.16.2019 @ 05:45 AM » #


Thanks. This worked…

I saw it clearly once I realized Apache was processing my php correctly whereas Windows wasn’t… due to the same extension discrepancy you’ve described.

I’m using an old version of MAMP and running PHP 5.3

What’s hilarious is all the people with advice like “Use PDO” or “PHP 5.3 is deprecated technology” They’re such n00bs…

If I had to guess the stock build of php shipped by MAMP points towards php7 extensions unless explicitly told otherwise… And perhaps they’re scripted into the assembly? That’s why Apache is saying “use the php5.3 ini” whereas Windows was saying “use this php7 stuff”

Just a guess…. Thanks again

by Mike on 05.24.2019 @ 11:34 AM » #

> leave a comment?