简体   繁体   English

无法保存 php.ini

[英]Can't save php.ini

I have PHP for FastCGI installed on Windows 7 through the Web Platform Installer.我通过 Web 平台安装程序在 Windows 7 上安装了用于 FastCGI 的 PHP。 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.我需要编辑 php.ini 以启用日志记录,但我无法覆盖现有文件,显然是因为某些内容已将其打开和/或锁定。

Stopping the server in IIS Manager doesn't help;在 IIS 管理器中停止服务器没有帮助; stopping the Windows Process Activation Service and the World Wide Web Publishing Service doesn't help.停止 Windows 进程激活服务和万维网发布服务无济于事。 phpinfo() confirms that I'm working with the correct file (C:\\Program Files (x86)\\PHP\\php.ini). phpinfo()确认我正在使用正确的文件 (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".在 Window Vista / Window 7 中,右键单击并选择“以管理员身份运行”。 Then open php.ini and edit it...然后打开php.ini并编辑它...

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'.另一种选择是将文件的文本复制到不同位置的新文件中,进行更改,将文件另存为“php.ini”。 Then copy the new file across overwriting the old one.然后复制新文件覆盖旧文件。 Explorer may handle the permissions differently. Explorer 可能会以不同的方式处理权限。

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:所以这就是我所做的:

  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".在 Windows 7 中,右键单击记事本并选择“以管理员身份运行”。 Make sure you do not use Notepad++ as your editor.确保您不使用 Notepad++ 作为您的编辑器。 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.您可以使用 Sysinternals(现在是 Microsoft 的一部分)的Process Explorer (直接 EXE 下载链接)的 Find Handle 功能来找出锁定文件的确切原因。

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.根据您尝试写入文件的内容,您可以改为写入站点根目录上的“.htaccess”文件。 I can provide a more specific example if you would like.如果您愿意,我可以提供更具体的示例。

You can also use Unlocker to figure this out.您也可以使用Unlocker来解决这个问题。 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.原始文件可能在别处,当服务器启动时,它会将其复制到 C:\\Program Files (x86)\\PHP\\php.ini。 phpinfo() might be pointing to the file that is overwritten every time... phpinfo() 可能指向每次都被覆盖的文件...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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