我不确定这个警告是什么时候开始的。我获得了一个现有的站点来进行托管,并应用了以下良好实践:
更新了Wordpress-从5.3到5.4.0(当前WP版本)
更新了所有插件-这是一个大列表,所以我不会将其添加到这里wp-content
可由Apache写入(内部有一些限制)->WordPress Hardening Guide请注意,Apache和PHP-FPM都使用Apache用户和组。我们只在这个网站上使用服务器(VM),所以我不必解决与进程共享相关的安全问题。
通过这些更改,我开始出现以下PHP警告(是的,我同时做了所有事情!很抱歉):
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_rmdir() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 381
Warning: ftp_nlist() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 402
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 226
Warning: ftp_pwd() expects parameter 1 to be resource, null given in /var/www/html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 681
每次调用服务器时,这些警告都会出现在PHP-FPM日志文件中。如果我设置
define( \'WP_DEBUG\', true );
它们可以在每一页中找到。
解决步骤我可以停止这些警告,执行以下操作之一:
禁用插件Swift Framework 和Redux Framework.将WordPress文件夹的文件所有权设置为Apache所有这些变化都不是理想的解决方案。第一个破坏了站点,第二个造成了安全问题。
WordPress bug
我还发现
WordPress issue 48689 这描述了相同的错误,但与不同的插件相关。然而,解决方案(
if (!defined(\'FS_METHOD\')) define(\'FS_METHOD\', \'direct\');
) 对我来说不行。剩下的选项是隐藏警告,这似乎不是一个好主意。