尽管将所有权作为root:apache
具有775和httpd运行权限apache
, Wordpress不喜欢这样。它希望所有者apache
, 根据wp-admin/includes/file.php
:
// Attempt to determine the file owner of the WordPress files, and that of newly created files
$wp_file_owner = $temp_file_owner = false;
if ( function_exists(\'fileowner\') ) {
$wp_file_owner = @fileowner( __FILE__ );
$temp_file_owner = @fileowner( $temp_file_name );
}
您的将是:
wp\\u file\\u owner=root
temp\\u file\\u owner=apache
if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
// WordPress is creating files as the same owner as the WordPress files,
// this means it\'s safe to modify & create new files via PHP.
$method = \'direct\';
$GLOBALS[\'_wp_filesystem_direct_method\'] = \'file_owner\';
} elseif ( $allow_relaxed_file_ownership ) {
// The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
// safely in this directory. This mode doesn\'t create new files, only alter existing ones.
$method = \'direct\';
$GLOBALS[\'_wp_filesystem_direct_method\'] = \'relaxed_ownership\';
}
如果$wp\\u file\\u owner与$temp\\u file\\u owner相同,则继续。你的会被抓到在elseif中,根据评论,它不允许删除/创建,只允许更新(我通过在Wordpress中更新插件的代码验证了这一点,并且成功了)。
请注意,我没有仔细查看代码,这只是我的快速解释。我也遇到了同样的问题,一旦我切换了user:group,使得httpd用户也是文件所有者,它就不再提示输入FTP凭据了。