php/iis:无法打开流:权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9210823/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:22:06  来源:igfitidea点击:

php/iis: failed to open stream: Permission denied

phpwindowsiisfopen

提问by arnab321

I am trying to do this:

我正在尝试这样做:

$fh = fopen("req2" , 'w')

and I get:

我得到:

Warning: fopen(D:\inetpub\wwwroot\req2) [function.fopen]: failed to open stream: Permission denied in D:\inetpub\wwwroot\test.php on line 44 can't open file

警告:fopen(D:\inetpub\wwwroot\req2) [function.fopen]: 无法打开流:第 44 行的 D:\inetpub\wwwroot\test.php 中的权限被拒绝无法打开文件

I gave "Full Control" permissions to IIS in the wwwroot directory. I had also tried the absolute path: $_SERVER['DOCUMENT_ROOT']."\\req2"

我在 wwwroot 目录中为 IIS 提供了“完全控制”权限。我也试过绝对路径:$_SERVER['DOCUMENT_ROOT']."\\req2"

but i still get the same error. I am running IIS 7 on Windows 7.

但我仍然遇到同样的错误。我在 Windows 7 上运行 IIS 7。

回答by Sohail Ahmed

In Windows, you need to give user, IUSRthe permission.

在 Windows 中,您需要授予用户IUSR权限。

回答by Beachhouse

Also, if you run into this with downloaded code, make sure that you have "unblocked" it to run locally.

此外,如果您使用下载的代码遇到此问题,请确保您已“解锁”它以在本地运行。

File encryption must also be disabled.

还必须禁用文件加密。

回答by xinthose

This worked for me:

这对我有用:

Right click folder --> Properties --> Security --> Edit --> allow Full Control --> apply --> do this for all, or just the correct user

右键单击文件夹 --> 属性 --> 安全 --> 编辑 --> 允许完全控制 --> 应用 --> 对所有人执行此操作,或仅对正确的用户执行此操作

回答by Peter Brand

Got this today on Windows 10 after I shared the wwwroot folder. Was working before that. Had to take the sharing off and reapply iis_iusr access permissions.

在我共享 wwwroot 文件夹后,今天在 Windows 10 上得到了这个。在那之前一直在工作。必须取消共享并重新申请 iis_iusr 访问权限。