views:

383

answers:

6
+1  Q: 

Can't save php.ini

I have PHP for FastCGI installed on Windows 7 through the Web Platform Installer. I need to edit php.ini to enable logging, but I'm not able to overwrite the existing file, apparently because something has it open and/or locked.

Stopping the server in IIS Manager doesn't help; stopping the Windows Process Activation Service and the World Wide Web Publishing Service doesn't help. phpinfo() confirms that I'm working with the correct file (C:\Program Files (x86)\PHP\php.ini). It's not marked as read only and I do have permissions for it. I'm out of ideas.

+1  A: 

You could use the Find Handle feature of Process Explorer (direct EXE download link), from Sysinternals (a part of Microsoft now), to find out what exactly is locking the file.

I'm sorry I can't help with your exact question, but hope that helps!

AKX
A: 

Depending on what are you trying to write to the file, you can write to an '.htaccess' file on the root of the site instead. I can provide a more specific example if you would like.

Phobis
A: 

You can also use Unlocker to figure this out. A pain, but the utility is really handy anyway so it won't hurt to have it around.

Karim
A: 

Try this:

  1. Stop the webserver
  2. Change the file
  3. Start the webserver

If that doesn't work, then you are probably changing the wrong file. It's possible that the original file is elsewhere and when the server starts it copies it to C:\Program Files (x86)\PHP\php.ini. phpinfo() might be pointing to the file that is overwritten every time...

milesmeow
+2  A: 

Another option is to copy the text of the file into a new file in a different location, make your changes, save the file as 'php.ini'. Then copy the new file across overwriting the old one. Explorer may handle the permissions differently.

PhilI
That did it! It looks like Windows wants you to elevate to administrator when you write something to Program Files, but neither Notepad nor Notepad++ were smart enough to tell me that.
phenry
+1  A: 

I had this problem and managed to work around it. You need to be running the editor (notepad or whatever) as an admin.

In Window Vista / Window 7, right click and choose "Run as Administrator". Then open php.ini and edit it...

Diego