由于只读属性,PHP mkdir权限被拒绝在Windows Server 2008 IIS 7上运行? [英] PHP mkdir Permission Denied running on Windows Server 2008 IIS 7 due to Read Only Attribute?

查看:1191
本文介绍了由于只读属性,PHP mkdir权限被拒绝在Windows Server 2008 IIS 7上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Server 2008上的IIS 7上运行的PHP网站出现问题。

I'm having a problem with a PHP website running on IIS 7 on Windows Server 2008.

有一行代码调用mkdir,这是错误的错误日志显示:

There is one line of code calling mkdir which is erroring and the error log reads:

...许可被拒绝......

"... permission denied ..."

我已经裁定与文件夹权限有任何关系(我尝试了多个组:Everyone,Users,IUSR,Network Service等没有运气)。

我需要知道mkdir是如何工作的,是否检查父文件夹的只读属性?

如果是,那么这可能是根问题是因为Windows Server 2008中的所有文件夹都标记为只读而复选框是灰色的 - 微软称它是按设计,但我认为它确实是糟糕的设计。

If so, then this could be the root of the problem as all folders in Windows Server 2008 are marked as "Read Only" and the checkbox is greyed-out - Microsoft say it is "by design" but I think it is really "bad design".

请帮忙。

PS可以在此处找到错误的代码行 https:// github .com / LimeSurvey / LimeSurvey / blob / 070d255ba381d7abcd231d7c9e0c7d11f5578c97 / admin / templates.php#L1182 这是第1182行。

P.S. The line of code which errors can be found here https://github.com/LimeSurvey/LimeSurvey/blob/070d255ba381d7abcd231d7c9e0c7d11f5578c97/admin/templates.php#L1182 it is line 1182.

解决方案:


  • 毕竟这是一个权限问题!

  • 我们正在将权限应用到错误的文件夹(从前额到手) / li>
  • 有两个模板文件夹:/模板和/上传/模板

  • /模板用于默认模板,而/上传/模板用于用户创建的

  • 我们给用户组提供了/上传/模板文件夹的执行/修改权限

  • 以前我们是将权限应用于/ Templates

  • 要调试此项,我使用 echo 输出 $ target value

  • It was a permissions issue after all!
  • We were applying permissions to the wrong folder (smacks hand to forehead)
  • There are two "Templates" folders: /Templates and /Uploads/Templates
  • /Template is for default templates whereas /Uploads/Templates is for user-created ones
  • We gave the "Users" group r/w/execute/modify permissions to /Uploads/Templates folder
  • Whereas previously we were applying permissions to /Templates
  • To debug this I used echo to output the $target value

LESSONS LE ARNT:

LESSONS LEARNT:


  • 始终阅读错误消息 - 它说许可被拒绝而且我不相信

  • 不要假设显而易见 - /模板不是正确的文件夹

  • 如果代码出错则调试代码并且不要试图猜测问题

  • 使用输出变量值等简单技术调试代码 - 例如回复

  • 倾听大多数人的意见 - 这里的大多数人都说这是一个允许的问题!

  • 大多数错误都有一个简单的解决方法 - 不要去找一些复杂的东西

  • Always read the error message - it said "permission denied" and I didn't believe it
  • Don't assume the obvious to be true - /Templates wasn't the right folder
  • If the code is erroring then debug the code and don't try to guess the problem
  • Debug the code using simple techniques such as outputting variable values - e.g. echo
  • Listen to the majority - most people here were right in saying IT IS A PERMISSIONS ISSUE!
  • Most errors have a simple fix - don't go looking for something complex

由于来自 mkdir()的有用引用而授予@BOMEz的赏金/ code>文档表明我应该双重考虑权限。 @BOMEz还提供了量身定制的答案,并通过帮助我的评论与我互动。

Bounty awarded to @BOMEz because of the useful quote from mkdir() documentation which indicated that I should double-think the permissions. @BOMEz also provided a tailored answer and interacted with me via comments which helped.

推荐答案


  • 作为测试(最好在开发环境中),为IIS用户提供对父文件夹的完全访问权限。如果这使它工作,慢慢开始取消权限,看看你需要哪些。

    • As a test (preferably in a development environment) give the IIS user full access to the parent folder. If this makes it work, slowly start taking away privileges to see which ones you need.

      尝试更改:

      if(mkdir($ target,0777) ))

      to:

      if(mkdir($ target))

      Windows忽略模式选项。可能是一些奇怪的错误导致它失败。

      Windows ignores the mode option. Might be some weird bug causing it to fail.

      另外,你的$ target变量可以尝试强制它链接到完整的Windows路径吗?例如 C:\Program Files \ IIS \ ...

      Additionally for your $target variable could you try forcing it to link to the full Windows path? Such as C:\Program Files\ IIS\...

      我遇到了情况使用Windows之前拒绝访问尝试使用相对路径,但完整路径工作正常。

      I've ran into situations with windows before where access was denied attempting to use a relative path, but the full path works just fine.

      编辑:
      查看文档上的注释对于 mkdir(),一位评论者提到您可能还需要添加执行对用户的权限:

      Looking at the comments on the documentation for mkdir() one commenter mentions that you might also need to add execute permissions to the user:


      如果您收到Permission Denied错误,但确定
      权限和所有权在哪里正在尝试创建目录
      是正确的,再次检查:

      If you're getting a Permission Denied error, but are certain the permissions and ownership where you are trying to create the directory are correct, check again:

      您尝试创建目录的位置必须具有
      执行尝试创建它的所有者的权限,无论
      的文件夹是可读的还是可写的。

      The location where you are trying to create the directory in must have the Execute permission for the owner trying to create it, regardless of if the folder is Readable, or Writable.

      这对某些人来说可能是显而易见的,但不是我起初希望
      这样可以省去我遇到的麻烦。

      This may be obvious to some, but was not to me at first. Hopefully this will save you the trouble I went through.

      这篇关于由于只读属性,PHP mkdir权限被拒绝在Windows Server 2008 IIS 7上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆