【问题标题】:Wordpress Linux file permissions and groupWordpress Linux 文件权限和组
【发布时间】:2013-06-15 02:54:03
【问题描述】:

我有一个 Linux 服务器 (Debian 7),有很多需要 Wordpress 的用户。当我创建用户时,他们应该在哪个组中?今天我将它们分配给www-data。 然后他们通过 SFTP 下载 Wordpress 并运行安装。

他们的文件应该有哪些文件权限和用户/组,特别是wp-config.php

现在,用户可以从终端互相窥视wp-config.php 并读取密码。不是很好。

由于用户不是 root,他们无法更改 wp-config.php 的文件权限/所有者,这将解决我的问题。

【问题讨论】:

    标签: linux wordpress file permissions


    【解决方案1】:

    您可以使用 Mike Conigliaro 的这个脚本来正确设置所有 wordpress 文件的权限。

    WP_OWNER=changeme # <-- wordpress owner
    WP_GROUP=changeme # <-- wordpress group
    WP_ROOT=/home/changeme # <-- wordpress root directory
    WS_GROUP=changeme # <-- webserver group
    
    # reset to safe defaults
    find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
    find ${WP_ROOT} -type d -exec chmod 755 {} \;
    find ${WP_ROOT} -type f -exec chmod 644 {} \;
    
    # allow wordpress to manage wp-config.php (but prevent world access)
    chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
    chmod 660 ${WP_ROOT}/wp-config.php
    
    # allow wordpress to manage .htaccess
    touch ${WP_ROOT}/.htaccess
    chgrp ${WS_GROUP} ${WP_ROOT}/.htaccess
    chmod 664 ${WP_ROOT}/.htaccess
    
    # allow wordpress to manage wp-content
    find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \;
    find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
    find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;
    

    【讨论】:

    • 如果您有礼貌地感谢作者,那就太好了。这只是几个额外的注释行?原文在这里:conigliaro.org/2010/05/06/…
    • 我已经拥有该脚本多年并且每天都在使用它。没有有意的先生,只是快速分享我所拥有的。
    【解决方案2】:

    我是这样解决的: 在组“users”中创建用户。在/etc/cron.hourly 中创建一个脚本,修复所有 wp-config.php 文件的权限,如下所示:

    for f in locate wp-config.php
    do
        chgrp www-data $f
        chmod 640 $f
    done
    

    像魅力一样工作。

    【讨论】:

      猜你喜欢
      • 2020-12-02
      • 2018-02-26
      • 2017-11-03
      • 2010-11-09
      • 2014-08-22
      • 2012-08-06
      • 1970-01-01
      • 2012-04-18
      相关资源
      最近更新 更多