EC2 上的 WordPress 需要 FTP 凭据才能安装插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17768201/
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
WordPress on EC2 Requires FTP Credentials to Install Plugins
提问by Anthony
I just installed WordPress 3.5.2 on an Amazon Linux AMI EC2 micro instance. When I tried to install the wp-db-backup plugin (Plugins -> Add New), I was prompted for a Hostname, FTP Username, FTP Password and Connection Type.
我刚刚在 Amazon Linux AMI EC2 微型实例上安装了 WordPress 3.5.2。当我尝试安装 wp-db-backup 插件(插件 -> 添加新)时,系统提示我输入主机名、FTP 用户名、FTP 密码和连接类型。
The answer to this questionrecommended that passwd
be done at the command line. I'm not clear on exactly what I'm doing at the commandline based on this answer. So I Googled and found an article on configuring vsftpd. The article discusses the generation of a certificate on the server and I'm wondering whether I'm going off track here by following this article. I'm using CentOS 6.3 locally, and an Amazon Linux AMI on EC2).
这个问题的答案建议passwd
在命令行中完成。根据这个答案,我不清楚我在命令行中到底在做什么。所以我用谷歌搜索并找到了一篇关于配置 vsftpd的文章。这篇文章讨论了在服务器上生成证书的问题,我想知道我是否会按照这篇文章在此处偏离轨道。我在本地使用 CentOS 6.3,在 EC2 上使用 Amazon Linux AMI)。
Any assistance/guidance will be appreciated. Thanks in advance.
任何帮助/指导将不胜感激。提前致谢。
EDIT
编辑
I was reading the WordPress Codexwhich discussed ftp constants for the wp-config.php file. It recommended that I define as few of these constants as needed to correct my update issues. I'm I on the right track here (especially security-wise)? I've listed the constants below. Any guidance will be appreciated.
我正在阅读WordPress Codex,其中讨论了 wp-config.php 文件的 ftp 常量。它建议我根据需要定义尽可能少的常量来纠正我的更新问题。我在这里走在正确的轨道上(尤其是安全方面)?我在下面列出了常量。任何指导将不胜感激。
define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/path/to/wordpress/');
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');
define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'ftp.example.org');
define('FTP_SSL', false);
回答by Basil Abbas
The main issue here is that apache does not have access to the folders. The default permission is given to the ec2-user in the AMI.
这里的主要问题是 apache 无法访问这些文件夹。默认权限授予 AMI 中的 ec2-user。
run this in your terminal and you should be good to go.
在你的终端中运行它,你应该很高兴。
sudo chown -R apache:apache /var/www/html
Once this is done you should be able to upload themes, plugins, updates etc.
完成此操作后,您应该能够上传主题、插件、更新等。
回答by Faizan Khan
Try this code in your wp config file
在您的 wp 配置文件中尝试此代码
define('FS_METHOD', 'direct');
回答by Saurabh Chandra Patel
change owner of wordpress directory
更改 wordpress 目录的所有者
sudo chown -R www-data:www-data /var/www/wordpress
OR try
或尝试
define('FS_METHOD', 'direct');
回答by Anthony
I found the answer to this question at Stephen White's blog post.
我在Stephen White 的博客文章中找到了这个问题的答案。
In a nutshell, I have to
简而言之,我必须
- create custom rules for Port Ranges 20-21 and some additional ports in my EC2 instance FW
- install and configure the FTP server vsftpd
- create and configure an FTP user
and put my FTP setting in the wp-config.php file
This works very well for me now.
- 为端口范围 20-21 和我的 EC2 实例固件中的一些其他端口创建自定义规则
- 安装和配置 FTP 服务器 vsftpd
- 创建和配置 FTP 用户
并将我的 FTP 设置放在 wp-config.php 文件中
这对我现在非常有效。
回答by usumoio
This worked for me:
这对我有用:
First follow what Faizan said to do and put the following line if your wp-config.php
:
首先按照 Faizan 所说的去做,如果你的wp-config.php
:
# you will want this as close to the bottom as possible
define('FS_METHOD', 'direct');
Then you need to TEMPORARILY swap your file permissions to a more open state. In the command line type the following:
然后您需要临时将您的文件权限交换到更开放的状态。在命令行中键入以下内容:
sudo chmod 777 -R /your_whole_wp_project
Now run your updates and then change the permissions back to something sane like:
现在运行您的更新,然后将权限更改回正常的内容,例如:
sudo chmod 664 -R /your_whole_wp_project
I'm aware this is a security issue and maybe not the best way to do this, but its the only thing I could try that got it to work for me.
我知道这是一个安全问题,也许不是最好的方法,但这是我唯一可以尝试让它对我来说有效的方法。
回答by Hugo Scavino
The 'define('FS_METHOD', 'direct');' suggestion worked for me after editing my security group in EC2 to allow outbound access to the port 443 (HTTPS)
'define('FS_METHOD', 'direct');' 在 EC2 中编辑我的安全组以允许对端口 443 (HTTPS) 的出站访问后,建议对我有用
回答by LComingHome
sudo chown -R www-data:www-data /var/www/html/wordpress
须藤 chown -R www-data:www-data /var/www/html/wordpress
the above command did the trick for me.
上面的命令对我有用。
回答by Kahitarich
For me it was a selinux issue. This did it for me: chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/
对我来说,这是一个 selinux 问题。这为我做到了:chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/
See: https://www.svnlabs.com/blogs/centos-7-selinux-apache-php-writeaccess-permission/
见:https: //www.svnlabs.com/blogs/centos-7-selinux-apache-php-writeaccess-permission/