linux - 在 Amazon EC2 (Amazon Linux) 上设置 WordPress 权限

标签 linux wordpress permissions amazon-ec2

我在 Amazon EC2 实例上安装了 WordPress。它使用 Amazon Linux 并且是标准设置(仅 php5 和 mysql)。

WordPress 工作正常,但存在一些权限问题。具体来说,我无法上传媒体、更新永久链接、插件等。我在 ec2-user 下没有写权限,因为我通过 WinSCP 上传了所有文件,当前所有者是 ec2-user。

我的问题是更正此问题的最佳方法是什么?我可能可以通过将所有文件夹/文件的所有权更改为 root 来修复它,但这不是一个非常优雅或动态的解决方案。

我的 web 目录的路径是/var/www/html。我可以授予 ec2-user 正确的权限吗?也许通过让 Apache 用户和 ec2-user 共享一个组?

任何想法将不胜感激

最佳答案

参见 http://blog.david-jensen.com/development/wordpress-amazon-ec2-apache-permissions-wordpress/在其他谷歌结果中。他看起来运气不错:

I have been doing my best to figure out the Amazon EC2 Apache setup of permissions to enable WordPress to be able to manage all of the files on my Amazon EC2 instance without WordPress asking for FTP permissions when I try to upload a plugin or theme via the Admin site. I ended up having to give file and group ownership of the files in my html folder to apache user for WordPress to run correctly. http://www.chrisabernethy.com/why-wordpress-asks-connection-info/ and its comments helped me reach this conclusion.

来自网页:

运行

sudo su chown -R apache:apache /vol/html

然后我将权限设置为强化 WordPress 指南为我的 html 根目录推荐的权限,因为当我运行具有多个域的 MultiSite 时,我的所有 WordPress 文件都在那里。

find /vol/html/ -type d -exec chmod 755 {} \;
find /vol/html/ -type f -exec chmod 644 {} \;

由于 apache 没有登录,我觉得冒这个险是值得的,尽管可能有更好的方法来做到这一点。然后我将 ec2-user 添加到 apache 组并将 wp-content 文件夹的权限更改为具有组写入权限 775。

useradd -G apache ec2-user
sudo chmod -R 775 /vol/html/wp-content

这允许 FileZilla 或以 ec2-user 身份登录的任何其他程序仅能够更改 wp-content 文件夹中的文件和文件夹。如果有人有更好的方法来做到这一点,我想知道。我只使用 SSH 和 SFTP 通过 key 文件访问服务器。

关于linux - 在 Amazon EC2 (Amazon Linux) 上设置 WordPress 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9545607/

相关文章:

android - GET_TASKS 权限已弃用

php - 使用 PHP 在 WP 中“主题化”我的 slider

php - 如何找到键为特定值的对象的索引?

ASP.NET 我可以在哪里写入而不修改权限?

linux - 什么是 centos LiveCD?

javascript - jQuery 脚本已加载但没有任何反应

permissions - 拒绝访问文件夹但不访问其中的文件

linux - 亚马逊 EC2 实例中 100% CPU 使用率的异常峰值

c - 需要一个shell脚本自动输入1-10000到程序中

c - 将文件封装在未压缩的 ZIP 文件中的简单库?