Wordpress 插件安装 - 无法连接到 FTP 服务器 - 最安全的解决方案?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21316282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:27:43  来源:igfitidea点击:

Wordpress Plugin Installation - Failed to connect to FTP Server - Safest Solution?

wordpressubuntunginxftp

提问by Omar Tariq

I succesfully set up a VPS LEMP-stack with Wordpress. When I am trying to install plugins from the WP backend, I am prompted with the following message:

我成功地使用 Wordpress 设置了 VPS LEMP 堆栈。当我尝试从 WP 后端安装插件时,系统提示我以下消息:

To perform the requested action, WordPress needs to access your web server. 
Please enter your FTP credentials to proceed. If you do not remember your 
credentials, you should contact your web host.

When I enter my SFTP-account details, which I am using to access the server with FileZilla, I get the following error message:

当我输入我用于通过 FileZilla 访问服务器的 SFTP 帐户详细信息时,我收到以下错误消息:

Failed to connect to FTP Server 192.XXX.XXX.X:21

I read varioustutorials, which suggest to install a FTP server, in particular vsftpdand then to store your FTP-User-details in the wp-config.php to avoid further authentication requestst. The problem I see is that, FTP is considered as severly unsecureand I would like to avoid hard-coding my user details into my WP-installation.

我阅读了各种教程,其中建议安装 FTP 服务器,尤其是vsftpd,然后将您的 FTP-User-details 存储在 wp-config.php 中以避免进一步的身份验证请求。我看到的问题是,FTP 被认为是非常不安全的,我想避免将我的用户详细信息硬编码到我的 WP 安装中。

What is the safest, recommended way to deal with this problem?

处理此问题的最安全、推荐的方法是什么?

回答by Omar Tariq

I don't know if it is the safest method or not. But pasting this code in wp-config.php once solved my problem:

我不知道这是否是最安全的方法。但是在 wp-config.php 中粘贴这段代码曾经解决了我的问题:

define('FS_METHOD', 'direct');

回答by kuldipem

sudo chown -R www-data:www-data wp_site_root
sudo chmod -R g+rw wp_site_root

solved my problem.

解决了我的问题。

回答by Flavio Troia

Remember to set files and directories permission in this way:

请记住以这种方式设置文件和目录权限:

chown -R www-data:www-data /var/www
find /var/www/ -type d -exec chmod 755 {} \;
find /var/www/ -type f -exec chmod 644 {} \;

回答by drishti ahuja

For me it was bitnami related settings issue. This posthelped me. There could be multiple reason:

对我来说,这是与 bitnami 相关的设置问题。这篇文章帮助了我。可能有多种原因:

  • Permission issue on the files and folders.
  • The FS_METHODshould be "direct" in wp-config.phpfile.
  • Remove FTP configuration from wp-config.phpif you are migrating from bitnamito manage it on your own.
  • 文件和文件夹的权限问题。
  • FS_METHOD应是“直接”wp-config.php的文件。
  • wp-config.php如果您要迁移,请删除 FTP 配置bitnami以自行管理它。

回答by Jeff Wooden

@MrNerdy,

@书呆子先生,

I should have also elaborated on the fact that there should be some other folders you'll want to give permissions to. Read the documentation on it here to understand exactly what you should do regarding security: http://codex.wordpress.org/Changing_File_Permissions

我还应该详细说明应该有一些其他文件夹您想要授予权限的事实。阅读此处的文档以准确了解您应该如何处理安全性:http: //codex.wordpress.org/Changing_File_Permissions

Also, be careful to only install trusted plugins. I've seen dozens of sites hacked because of badly coded plugins / themes, etc. Good luck.

此外,请注意仅安装受信任的插件。我已经看到数十个网站因为插件/主题编码错误等而被黑。祝你好运。

回答by hitautodestruct

If anyone is running into this issue using MAMP Pro.

如果有人使用 MAMP Pro 遇到此问题。

Make sure you're running the server as the user that has permission for the root wordpress directory.

确保您以对 wordpress 根目录具有权限的用户身份运行服务器。

Under SETTINGS > Portslook for "Run server as" and in the drop down choose the same system user that has permission to access the root wp folder.

SETTINGS > Ports查找“运行服务器为”并在下拉列表中选择有权访问根 wp 文件夹的相同系统用户。

enter image description here

在此处输入图片说明

回答by Venkey Hit

if your'e using shared hosting then remove some files in your server and try again. it will work. its because your disk quota may be exceeded.

如果您使用共享主机,请删除服务器中的一些文件,然后重试。它会起作用。这是因为您的磁盘配额可能已超出。