WordPress 要求我提供 FTP 凭据以安装插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17922644/
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:18:49  来源:igfitidea点击:

WordPress asking for my FTP credentials to install plugins

wordpressftp

提问by sasi kanth

I installed a WordPress blog in my local system. But when I try to add plugins from admin it asks for FTP access. What do I need to configure for WordPress to be able to upload without FTP?

我在本地系统中安装了一个 WordPress 博客。但是当我尝试从管理员添加插件时,它要求 FTP 访问。我需要为 WordPress 配置什么才能在没有 FTP 的情况下上传?

回答by nickle

Try to add the code in wp-config.php:

尝试在 wp-config.php 中添加代码:

define('FS_METHOD', 'direct');

回答by Nanhe Kumar

If you are using Ubuntu.

如果您使用的是 Ubuntu。

sudo chown -R www-data:www-data PATH_TO_YOUR_WORDPRESS_FOLDER

回答by Aboozar Rajabi

"Whenever you use the WordPress control panel to automatically install, upgrade, or delete plugins, WordPress must make changes to files on the filesystem.

“每当您使用 WordPress 控制面板自动安装、升级或删除插件时,WordPress 都必须对文件系统上的文件进行更改。

Before making any changes, WordPress first checks to see whether or not it has access to directly manipulate the file system.

在进行任何更改之前,WordPress 首先检查它是否有权直接操作文件系统。

If WordPress does not have the necessary permissions to modify the filesystem directly, you will be asked for FTP credentials so that WordPress can try to do what it needs to via FTP."

如果 WordPress 没有直接修改文件系统的必要权限,您将被要求提供 FTP 凭据,以便 WordPress 可以尝试通过 FTP 执行它需要的操作。”

Solution: In order to find out what user your instance of apache is running as, create a test script with the following content:

解决方案:为了找出您的 apache 实例正在以哪个用户身份运行,请创建一个包含以下内容的测试脚本:

<?php echo(exec("whoami")); ?>

For me, it was daemon and not www-data. Then, fix the permission by:

对我来说,它是守护进程而不是 www-data。然后,通过以下方式修复权限:

sudo chown -R daemon /path/to/your/local/www/folder

回答by Kenny

On OSX, I used the following, and it worked:

在 OSX 上,我使用了以下内容,并且有效:

sudo chown -R _www:_www {path to wordpress folder}

_www is the user that PHP runs under on the Mac.

_www 是在 Mac 上运行 PHP 的用户。

(You may also need to chmod some folders too. I had done that first and it didn't fix it. It wasn't until I did the chown command that it worked, so I'm not sure if it was the chown command alone, or a combination of chmod and chown.)

(您可能还需要 chmod 一些文件夹。我先做了,但它没有修复它。直到我执行 chown 命令它才起作用,所以我不确定它是否是 chown 命令单独使用,或 chmod 和 chown 的组合。)

回答by KawaiKx

I changed the ownership of the wordpress folder to www-data recursively and restarted apache.

我递归地将 wordpress 文件夹的所有权更改为 www-data 并重新启动了 apache。

sudo chown -R www-data:www-data <folderpath>

It worked like a charm!

它就像一个魅力!

回答by Niels Keurentjes

From the first hit on Google:

从 Google 上的第一次点击开始

WordPress asks for your FTP credentials when it can't access the files directly. This is usually caused by PHP running as the apache user (mod_php or CGI) rather than the user that owns your WordPress files.

当 WordPress 无法直接访问文件时,它会要求您提供 FTP 凭据。这通常是由于 PHP 以 apache 用户(mod_php 或 CGI)而不是拥有 WordPress 文件的用户身份运行所致。

This is rather normal in most shared hosting environments - the files are stored as the user, and Apache runs as user apacheor httpd. This is actually a good security precaution so exploits and hacks cannot modify hosted files. You could circumvent this by setting all WP files to 777 security, but that means nosecurity, so I would highly advise against that. Just use FTP, it's the automatically advised workaround with good reason.

这在大多数共享托管环境中相当正常——文件以用户身份存储,Apache 以用户身份apachehttpd. 这实际上是一个很好的安全预防措施,因此漏洞和黑客无法修改托管文件。您可以通过将所有 WP 文件设置为 777 安全性来规避此问题,但这意味着没有安全性,因此我强烈建议您不要这样做。只需使用 FTP,这是有充分理由的自动建议解决方法。

回答by Benja Garrido

First move to your installation folder (for example)

首先移动到您的安装文件夹(例如)

cd /Applications/XAMPP/xamppfiles/

Now we're going to modify your htdocs directory:

现在我们要修改你的 htdocs 目录:

sudo chown -R daemon htdocs

Enter your root password when prompted, then finish it out with a chmod call:

出现提示时输入您的 root 密码,然后使用 chmod 调用完成它:

sudo chmod -R g+w htdocs

回答by malta

We had the same problem as part of a bigger problem. The suggested solution of

作为更大问题的一部分,我们遇到了同样的问题。建议的解决方案

define('FS_METHOD', 'direct');

hides that window but then we still had problems with loading themes and upgrades etc. It is related to permissions however in our case we fixed the problem by moving from php OS vendor mod_phpto the more secure php OS vendor FastCGI application.

隐藏了那个窗口,但是我们在加载主题和升级等方面仍然存在问题。它与权限有关,但是在我们的例子中,我们通过从php OS 供应商 mod_php移动到更安全的php OS 供应商 FastCGI 应用程序来解决问题

回答by Hiren Gohel

I did a local install of WordPress on Ubuntu 14.04 following the steps outlined hereand simply running:

我按照此处列出的步骤在 Ubuntu 14.04 上本地安装了 WordPress,然后简单地运行:

sudo chown -R www-data:www-data {path_to_your_project_directory}

solved my issue with downloading plugins. The only reason I'm leaving this post here is because when I googled my issue, this was one of the first results and it led me to the solution to my problem.

解决了我下载插件的问题。我把这篇文章留在这里的唯一原因是当我用谷歌搜索我的问题时,这是第一个结果,它让我找到了我的问题的解决方案。

Hope this one helps to anyone!

希望这对任何人都有帮助!

回答by Abhishek Rathore

If during installation of a plugin, Wordpress asks for your hostname or FTP details. Then follow these steps:

如果在安装插件期间,Wordpress 会询问您的主机名或 FTP 详细信息。然后按照以下步骤操作:

Login to your server and navigate to /var/www/html/wordpress/. Open wp-config.php and add this line after define(‘DB_COLLATE')

登录到您的服务器并导航到/var/www/html/wordpress/。打开 wp-config.php 并在 define('DB_COLLATE') 之后添加这一行

define('FS_METHOD', 'direct');

If you get "Could not create directory" error. Give write permissions to your wordpress directory in recursive as

如果您收到“无法创建目录”错误。以递归方式为您的 wordpress 目录授予写权限

chmod -R go+w wordpress

NOTE. For security, revoke these permissions once you install a plugin as

笔记。为了安全起见,一旦您将插件安装为

chmod -R go-w wordpress