简体   繁体   中英

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.

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...

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.

I've had a similar problem, and I was working in windows 10 which doesn't use "run as administrator"

So this is what I did:

  1. right click the problem file and go to properties
  2. go to tab security
  3. click edit, which should have a shield
  4. select in names of groups: Users(computer specifics\\Users)
  5. in the square under it you can allow editing of the file

This causes it to allow you to edit the file for users and not run into the problem anymore. This also removes the problem in the future for this file so you can always edit it again by just opening the file in text editor.

Please note I am Dutch and that certain names are translated incorrectly.

In Windows 7, right click Notepad and choose "Run as Administrator". Make sure you do not use Notepad++ as your editor. It accesses this file and therefore tells you there's is an error.

The default notepad will work fine with these instructions.

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!

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.

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM