简体   繁体   English

解决IIS7上WordPress的权限问题

[英]Resolving Permissions Problems for WordPress on IIS7

I am running WordPress on Win2k8/IIS7 (using httpcache, fastCgi & UrlRewriter 2.0) installed via WPI. 我在通过WPI安装的Win2k8 / IIS7(使用httpcache,fastCgi和UrlRewriter 2.0)上运行WordPress。 Everything seems to be working fine (uploads, posting via Live Writer, comments, plugins, pretty URLs). 一切似乎都工作正常(上传,通过Live Writer发布,注释,插件,漂亮的URL)。

I am trying to update WordPress to the latest version, but I get an error like this: 我正在尝试将WordPress更新到最新版本,但出现如下错误:

Download failed. 下载失败。 Destination directory for file streaming does not exist or is not writable 文件流的目标目录不存在或不可写

This is the same error that I get when trying to download a theme or update a plugin. 这与尝试下载主题或更新插件时遇到的错误相同。

There are no errors in the event log and WordPress isn't really telling me which directory it's looking for, what user it thinks it's using or what permission it is lacking. 事件日志中没有错误,并且WordPress并没有真正告诉我它要查找的目录,它认为正在使用的用户或缺少的权限。

I have double (and triple) checked that the IIS App Pool user is explicitly set, and that the directory has modify permissions for that user, and finally that those permissions have been propogated down to sub folders. 我已经进行了两次(三次)检查,以确定是否已设置IIS App Pool用户,并且该目录具有对该用户的修改权限,最后,这些权限已传播到子文件夹中。

At the advice of Dr. Google, I have also added the following settings to the config file: 在Google博士的建议下,我还向配置文件添加了以下设置:

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

define('WP_TEMP_DIR', ABSPATH . 'wp-content/');
define('FS_METHOD', 'direct'); 

Am I missing a config option or a setting? 我是否缺少配置选项或设置? Does WordPress require the sacrifice of a small kitten and/or an Algerian degu? WordPress是否需要牺牲一只小猫和/或阿尔及利亚degu?

From the PHP manual on IIS7 installation (emphasis mine): 有关IIS7安装PHP手册 (重点是我的):

Impersonation and file system access 模拟和文件系统访问

It is recommended to enable FastCGI impersonation in PHP when using IIS. 建议使用IIS时在PHP中启用FastCGI模拟。 This is controlled by the fastcgi.impersonate directive in php.ini file . 这由php.ini文件中的fastcgi.impersonate指令控制。 When impersonation is enabled, PHP will perform all the file system operations on behalf of the user account that has been determined by IIS authentication . 启用模拟功能后,PHP将代表由IIS身份验证确定的用户帐户执行所有文件系统操作。 This ensures that even if the same PHP process is shared across different IIS web sites, the PHP scripts in those web sites will not be able to access each other's files as long as different user accounts are used for IIS authentication on each web site. 这样可以确保即使在不同的IIS网站上共享相同的PHP进程,只要每个网站上的IIS身份验证使用不同的用户帐户,这些网站中的PHP脚本也将无法访问彼此的文件。

For example IIS 7, in its default configuration, has anonymous authentication enabled with built-in user account IUSR used as a default identity. 例如,IIS 7在其默认配置中启用了匿名身份验证,并将内置用户帐户IUSR用作默认身份。 This means that in order for IIS to execute PHP scripts, it is necessary to grant IUSR account read permission on those scripts. 这意味着,为了使IIS执行PHP脚本,必须向IUSR帐户授予对这些脚本的读取权限。 If PHP applications need to perform write operations on certain files or write files into some folders then IUSR account should have write permission to those. 如果PHP应用程序需要对某些文件执行写操作或将文件写到某些文件夹中,则IUSR帐户应对此具有写权限。

As discussed in the "Should I impersonate PHP via FastCGI?" “我应该通过FastCGI模拟PHP吗?”中讨论的那样。 question on ServerFault , there are security concerns if you would grant the anonymous user write access rights on your server. 关于ServerFault的问题,是否要授予匿名用户对服务器的写访问权,存在安全性问题。 For instance, if you have also enabled the WebDAV module, anyone could write to your directories using this protocol! 例如,如果您还启用了WebDAV模块,则任何人都可以使用此协议写入目录!

Therefore my recommendations are: 因此,我的建议是:

  1. Ensure all your sites have their own unique Application Pool assigned. 确保所有站点都分配了自己唯一的应用程序池
  2. In the Advanced Settings under Processing Model for the application pool, set the built-in account as ApplicationPoolIdentity . 在应用程序池的 处理模型 下的“ 高级设置”中 ,将内置帐户设置为ApplicationPoolIdentity
  3. Disable impersonation in php.ini with fastcgi.impersonate = 0 , so PHP runs under the Application Pool Identity as set in IIS. 使用fastcgi.impersonate = 0禁用php.ini中的模拟,因此PHP在IIS中设置的“ 应用程序池标识”下运行。
  4. Set read/write permissions on your folders using the automatically generated application pool user account (eg "IIS AppPool\\MyAppPoolName"). 使用自动生成的应用程序池用户帐户 (例如“ IIS AppPool \\ MyAppPoolName”)设置文件夹的读/写权限。

This way, all PHP scripts are ensured to run under a system account, tied to the Application Pool of the site (isolating it from other sites), and cannot accidentally get too public access via impersonation. 这样,可以确保所有PHP脚本都在系统帐户下运行,并与站点的应用程序池关联(将其与其他站点隔离),并且不会通过模拟意外地获得过多的公共访问权限。

Correct me if I'm wrong but I believe the following configuration provides the same benefits, and also honors PHP's desired setting of fastcgi.impersonate=1. 如果我错了,请指正我,但我相信以下配置可提供相同的好处,并且也尊重PHP所需的fastcgi.impersonate = 1设置。

Steps 1,2 and 4 are the same - step 3 is different. 步骤1,2和4相同-步骤3不同。

  1. Ensure each site has its own application pool (same as above) 确保每个站点都有自己的应用程序池(与上面相同)
  2. Under Advanced Settings > Processing Model > Application Pool Identity (same as above) 在“高级设置”>“处理模型”>“应用程序池标识”下(与上面相同)
  3. IIS > Authentication > Anonymous Authentication > Application Pool Identity (not IUSR) IIS>身份验证>匿名身份验证>应用程序池标识(不是IUSR)
  4. Set read/write permissions using IIS AppPool\\MyAppPoolName (same as above) 使用IIS AppPool \\ MyAppPoolName设置读取/写入权限(与上面相同)

We do not grant IUSR or IIS_IUSRS access to the webroot. 我们不授予IUSR或IIS_IUSRS访问Webroot的权限。 All permissions are assigned to IIS AppPool\\MyAppPoolName 所有权限都分配给IIS AppPool \\ MyAppPoolName

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

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