在 ec2 上更新 wordpress 主题

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

Update wordpress theme on ec2

wordpressamazon-ec2

提问by Spencer Carnage

I'm hosting a wordpress site on ec2 and I'm trying to update my theme through the admin screen. Its asking me for Hostname and ftp username and password. Is ec2-xxx.compute-1.amazonaws.com:22 my hostname? I tried along with ec2user and root for my ftp username but no luck. What am I doing wrong?

我在 ec2 上托管了一个 wordpress 网站,我正在尝试通过管理屏幕更新我的主题。它要求我提供主机名和 ftp 用户名和密码。ec2-xxx.compute-1.amazonaws.com:22 是我的主机名吗?我为我的 ftp 用户名尝试了 ec2user 和 root,但没有运气。我究竟做错了什么?

采纳答案by ceejayoz

Your hostname would be ec2-107-20-192-98.compute-1.amazonaws.com.

您的主机名将是ec2-107-20-192-98.compute-1.amazonaws.com.

Your username will be the username you use to SFTP to the instance normally - ec2user for some instance types, ubuntu for Ubuntu AMIs, etc. EC2 generally doesn't use passwords, preferring SSH keys, so you'll have to set a password for your account by doing passwdon the commandline.

您的用户名将是您通常用于 SFTP 到实例的用户名 - ec2user 用于某些实例类型,ubuntu 用于 Ubuntu AMI 等。EC2 通常不使用密码,首选 SSH 密钥,因此您必须为通过passwd在命令行上执行您的帐户。

回答by Jake

Skip the FTP info altogether and just change the permission of the directory structure where Wordpress is installed.

完全跳过 FTP 信息,只需更改安装 Wordpress 的目录结构的权限。

VIA SSH

通过 SSH

sudo chown -R apache:apache path/to/wordpress
  • sudomakes sure you execute as the root user
  • chownwill change the owner of the directory
  • -Rwill make it recursive, so it changes all files and directories within
  • apache:apacheis user:group
  • sudo确保您以 root 用户身份执行
  • chown将改变目录的所有者
  • -R将使其递归,因此它会更改其中的所有文件和目录
  • apache:apache是用户:组

And then the path to wordpress. Could be /var/www/html/sitename.com or if you navigate to the folder where Wordpress is installed, you can use a period (.) to tell it to change the current directory.

然后是wordpress的路径。可能是 /var/www/html/sitename.com 或者如果您导航到安装 Wordpress 的文件夹,您可以使用句点 (.) 告诉它更改当前目录。

This will make is so that you can't copy files via sftp though, so it is good to change at least the themes directory back to the ec2-user:ec2-user user and group.

这将使您无法通过 sftp 复制文件,因此最好至少将主题目录更改回 ec2-user:ec2-user 用户和组。

So this changes back to your ssh/sftp user:

因此,这将更改回您的 ssh/sftp 用户:

sudo chown -R ec2-user:ec2-user path/to/wordpress

You can assign the folders to the ftp user and the apache group and then make them group writable as well. This will allow you to ftp into the directory, and allow everything to be auto updated within Wordpress.

您可以将文件夹分配给 ftp 用户和 apache 组,然后将它们设置为可写组。这将允许您通过 ftp 进入该目录,并允许在 Wordpress 中自动更新所有内容。

// Set the wp-contents into the apache group and then make files group writable
sudo chgrp -R apache wp-content
sudo chmod -R g+w wp-content
// This makes new files created in wp-content and all of its sub-directories group-writable.
sudo chmod g+s wp-content

Then add this to wp-config.php to force Wordpress to update when only applying this wp-content:

然后将此添加到 wp-config.php 以强制 Wordpress 在仅应用此 wp-content 时进行更新:

define('FS_METHOD', 'direct');

You can also apply to the whole Wordpress install to auto update Wordpress and not just plugins/themes. If you do this, I would recommend putting your wp-config.php file one directory above your Wordpress install though, so you can lock it down separately.

您还可以申请整个 Wordpress 安装以自动更新 Wordpress 而不仅仅是插件/主题。如果您这样做,我建议您将 wp-config.php 文件放在 Wordpress 安装上方的一个目录中,以便您可以单独锁定它。

EDIT: Whenever I am having permission troubles on EC2, I go to siteroot directory, and paste these lines in. I apply it to the whole Wordpress install these days:

编辑:每当我在 EC2 上遇到权限问题时,我都会转到站点根目录,然后粘贴这些行。这些天我将其应用于整个 Wordpress 安装:

sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
sudo chown -R ec2-user:apache .
sudo chmod -R g+w .
sudo chmod g+s .

I use something similar on my Mac as well.

我也在我的 Mac 上使用类似的东西。

回答by Rohan Zakie

In your wp-config.phpunder directivesadd this line:

在你的wp-config.php下面directives添加这一行:

define('FS_METHOD', 'direct');

回答by Tim Chen

You can simply solve this problem by doing this via ssh:

您可以通过 ssh 执行此操作来简单地解决此问题:

sudo chown -R apache path/to/wordpress

sudo chown -R apache path/to/wordpress

then

然后

sudo chmod -R 755 path/to/wordpress

sudo chmod -R 755 path/to/wordpress

回答by markratledge

Try adding FTP credentials to wp-config.php: http://codex.wordpress.org/Editing_wp-config.phpand http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants

尝试将 FTP 凭据添加到 wp-config.php:http: //codex.wordpress.org/Editing_wp-config.phphttp://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants

That should make WP admin stop asking for FTP details. But depending on how you've set up permissions via the command line, may have to go to the command line to edit files like wp-config.php . And you may not have sufficient permissions to upload and for WP to unzip a theme.

这应该让 WP 管理员停止询问 FTP 详细信息。但是根据您通过命令行设置权限的方式,可能必须转到命令行来编辑 wp-config.php 等文件。而且您可能没有足够的权限来上传和让 WP 解压缩主题。

As per other answers, I use SFTP with a server of ec2-xx-xxx-xx-xx.compute-1.amazonaws.comusername of ec2-user

根据其他答案,我将 SFTP 与ec2-xx-xxx-xx-xx.compute-1.amazonaws.com用户名的 服务器一起使用ec2-user

回答by sarnold

ec2-107-20-192-98.compute-1.amazonaws.com:22represents both the hostname andthe sshport. (SSH is normally on port 22, though it can run on any port.)

ec2-107-20-192-98.compute-1.amazonaws.com:22既代表的主机名ssh端口。(SSH 通常在 port 上22,但它可以在任何端口上运行。)

Try just ec2-107-20-192-98.compute-1.amazonaws.comin the hostname field.

ec2-107-20-192-98.compute-1.amazonaws.com在主机名字段中尝试。

I'm still skeptical of a webpageasking for a username and password. Seems a bit silly to me, since you should just use SFTP to directly upload whatever content you want using your SSH identity key instead of a password.

我仍然对要求用户名和密码的网页持怀疑态度。对我来说似乎有点傻,因为您应该使用 SFTP 直接上传您想要使用 SSH 身份密钥而不是密码的任何内容。

回答by Nico Pernice

You could simply use 127.0.0.1 as hostname and check FTP in Wordpress ftp settings. To resume what has been said:

您可以简单地使用 127.0.0.1 作为主机名并在 Wordpress ftp 设置中检查 FTP。继续说的话:

  • useris the same you actually use to SSH/SFTP

  • passwordneeds to be set/updated logging in via SSH and typing sudo passwd your-user-name

  • 用户与您实际用于 SSH/SFTP 的用户相同

  • 需要设置/更新密码,通过 SSH 登录并输入 sudo passwd your-user-name