• <tfoot id='81Zrx'></tfoot>
        <bdo id='81Zrx'></bdo><ul id='81Zrx'></ul>
      <legend id='81Zrx'><style id='81Zrx'><dir id='81Zrx'><q id='81Zrx'></q></dir></style></legend>
    1. <small id='81Zrx'></small><noframes id='81Zrx'>

    2. <i id='81Zrx'><tr id='81Zrx'><dt id='81Zrx'><q id='81Zrx'><span id='81Zrx'><b id='81Zrx'><form id='81Zrx'><ins id='81Zrx'></ins><ul id='81Zrx'></ul><sub id='81Zrx'></sub></form><legend id='81Zrx'></legend><bdo id='81Zrx'><pre id='81Zrx'><center id='81Zrx'></center></pre></bdo></b><th id='81Zrx'></th></span></q></dt></tr></i><div id='81Zrx'><tfoot id='81Zrx'></tfoot><dl id='81Zrx'><fieldset id='81Zrx'></fieldset></dl></div>

        由于只读属性,PHP mkdir 权限被拒绝在 Windows Server 2008 IIS 7 上运行?

        时间:2023-10-12
        <tfoot id='6qLm8'></tfoot>
      1. <i id='6qLm8'><tr id='6qLm8'><dt id='6qLm8'><q id='6qLm8'><span id='6qLm8'><b id='6qLm8'><form id='6qLm8'><ins id='6qLm8'></ins><ul id='6qLm8'></ul><sub id='6qLm8'></sub></form><legend id='6qLm8'></legend><bdo id='6qLm8'><pre id='6qLm8'><center id='6qLm8'></center></pre></bdo></b><th id='6qLm8'></th></span></q></dt></tr></i><div id='6qLm8'><tfoot id='6qLm8'></tfoot><dl id='6qLm8'><fieldset id='6qLm8'></fieldset></dl></div>
          <bdo id='6qLm8'></bdo><ul id='6qLm8'></ul>
            • <small id='6qLm8'></small><noframes id='6qLm8'>

            • <legend id='6qLm8'><style id='6qLm8'><dir id='6qLm8'><q id='6qLm8'></q></dir></style></legend>

                    <tbody id='6qLm8'></tbody>
                  本文介绍了由于只读属性,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 ..."

                  我已经排除了与文件夹权限有关的任何事情(我尝试了多个组:所有人、用户、IUSR、网络服务等,但都没有成功).

                  我需要知道 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".

                  请帮忙.

                  附言可以在此处找到错误的代码行 https://github.com/LimeSurvey/LimeSurvey/blob/070d255ba381d7abcd231d7c9e0c7d11f5578c97.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.

                  解决方案:

                  • 毕竟是权限问题!
                  • 我们对错误的文件夹应用了权限(用手拍额头)
                  • 有两个模板"文件夹:/Templates 和/Uploads/Templates
                  • /Template 用于默认模板,而/Uploads/Templates 用于用户创建的模板
                  • 我们授予用户"组对/Uploads/Templates 文件夹的 r/w/execute/modify 权限
                  • 而之前我们将权限应用于/Templates
                  • 为了调试这个,我使用了 echo 来输出 $target
                  • 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

                  经验教训:

                  • 总是阅读错误消息 - 它说权限被拒绝",我不相信
                  • 不要假设明显是真的 -/Templates 不是正确的文件夹
                  • 如果代码出错,请调试代码,不要试图猜测问题
                  • 使用简单的技术调试代码,例如输出变量值 - 例如回声
                  • 听听大多数人的意见 - 这里的大多数人说这是一个权限问题是正确的!
                  • 大多数错误都有一个简单的修复方法 - 不要去寻找复杂的东西

                  由于 mkdir() 文档中的有用引述,@BOMEz 获得了赏金,这表明我应该仔细考虑权限.@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))

                      到:

                      if(mkdir($target))

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

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

                      另外,对于您的 $target 变量,您可以尝试强制它链接到完整的 Windows 路径吗?如C:Program FilesIIS...

                      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 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 和文件写入权限 下一篇:php.ini 中的 log_errors_max_len = 1024,但 php 日志一直在增长

                  相关文章

                    <tfoot id='bC7tY'></tfoot>
                      <bdo id='bC7tY'></bdo><ul id='bC7tY'></ul>

                      <i id='bC7tY'><tr id='bC7tY'><dt id='bC7tY'><q id='bC7tY'><span id='bC7tY'><b id='bC7tY'><form id='bC7tY'><ins id='bC7tY'></ins><ul id='bC7tY'></ul><sub id='bC7tY'></sub></form><legend id='bC7tY'></legend><bdo id='bC7tY'><pre id='bC7tY'><center id='bC7tY'></center></pre></bdo></b><th id='bC7tY'></th></span></q></dt></tr></i><div id='bC7tY'><tfoot id='bC7tY'></tfoot><dl id='bC7tY'><fieldset id='bC7tY'></fieldset></dl></div>

                    1. <small id='bC7tY'></small><noframes id='bC7tY'>

                    2. <legend id='bC7tY'><style id='bC7tY'><dir id='bC7tY'><q id='bC7tY'></q></dir></style></legend>