无法保存 php.ini
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1902800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't save php.ini
提问by phenry
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.
我通过 Web 平台安装程序在 Windows 7 上安装了用于 FastCGI 的 PHP。我需要编辑 php.ini 以启用日志记录,但我无法覆盖现有文件,显然是因为某些内容已将其打开和/或锁定。
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.
在 IIS 管理器中停止服务器没有帮助;停止 Windows 进程激活服务和万维网发布服务无济于事。phpinfo()确认我正在使用正确的文件 (C:\Program Files (x86)\PHP\php.ini)。它没有标记为只读,我确实有权限。我没有想法了。
回答by Digs
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...
在 Window Vista / Window 7 中,右键单击并选择“以管理员身份运行”。然后打开php.ini并编辑它...
回答by Phil
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.
另一种选择是将文件的文本复制到不同位置的新文件中,进行更改,将文件另存为“php.ini”。然后复制新文件覆盖旧文件。Explorer 可能会以不同的方式处理权限。
回答by AKX
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.
您可以使用Sysinternals(现在是 Microsoft 的一部分)的Process Explorer(直接 EXE 下载链接)的 Find Handle 功能来找出锁定文件的确切原因。
I'm sorry I can't help with your exact question, but hope that helps!
很抱歉,我无法回答您的确切问题,但希望对您有所帮助!
回答by Badmash
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.
在 Windows 7 中,右键单击记事本并选择“以管理员身份运行”。确保您不使用 Notepad++ 作为您的编辑器。它访问这个文件,因此告诉你有一个错误。
The default notepad will work fine with these instructions.
默认记事本可以按照这些说明正常工作。
回答by RensBe
I've had a similar problem, and I was working in windows 10 which doesn't use "run as administrator"
我遇到了类似的问题,我在不使用“以管理员身份运行”的 Windows 10 中工作
So this is what I did:
所以这就是我所做的:
- right click the problem file and go to properties
- go to tab security
- click edit, which should have a shield
- select in names of groups: Users(computer specifics\Users)
- 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.
请注意我是荷兰人,某些名称翻译不正确。
回答by Phobis
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.
根据您尝试写入文件的内容,您可以改为写入站点根目录上的“.htaccess”文件。如果您愿意,我可以提供更具体的示例。
回答by Karim
回答by milesmeow
Try this:
尝试这个:
- Stop the webserver
- Change the file
- 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...
如果这不起作用,那么您可能更改了错误的文件。原始文件可能在别处,当服务器启动时,它会将其复制到 C:\Program Files (x86)\PHP\php.ini。phpinfo() 可能指向每次都被覆盖的文件...

