核心更新所需的用户、组和权限

时间:2015-02-04 作者:luukvhoudt

核心更新需要哪些用户、组以及文件和文件夹的权限?

测试设置我什么都试过了the manual 推荐我去。下面是我使用的一些测试设置,该设置是在WordPress安装中递归使用的。

案例A:所有者具有读/写权限以上每个权限案例都是通过以下用户和组设置进行尝试的。

所有者:Apache组:Apache测试结果1A:

Could not create directory.

  • 1B:

    Could not create directory
    

  • 2A:

    Could not create directory.
    

  • 2B:

    The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php
    

  • 3A:

    Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155
    Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457
    Download failed.: Destination directory for file streaming does not exist or is not writable.
    

  • 3B:

    Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155
    Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457
    Download failed.: Destination directory for file streaming does not exist or is not writable.
    

  • 4A:

    Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155
    Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457
    Download failed.: Destination directory for file streaming does not exist or is not writable.
    

  • 4B:

    The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php
    
    这些更新一直是WordPress的一个大问题,我想澄清一下,让我们找到一个通用的解决方案!安装托管在运行DirectAdmin的CentOS 6.6服务器上。

    编辑:wp config处的自定义配置。我用于这些测试的php包含以下内容:

    $root=\'public_html\';
    define(\'FTP_USER\',\'username\');
    define(\'FTP_PASS\',\'password\');
    
    $addr=$_SERVER[\'SERVER_ADDR\'];
    $name=$_SERVER[\'SERVER_NAME\'];
    $host=$_SERVER[\'HTTP_HOST\'];
    $https=$_SERVER[\'HTTPS\'];
    $protocol=(!empty($https)&&$https!==\'off\'||$_SERVER[\'SERVER_PORT\']===443)?\'https://\':\'http://\';
    $abspath=(strpos(getcwd(),\'/wp-admin\')!==FALSE)?substr(getcwd(),0,strrpos(getcwd(),\'/wp-admin\')):getcwd();
    $relpath=substr($abspath,strrpos($abspath,$root)+strlen($root));
    define(\'WP_HOME\',$protocol.$host.$relpath);
    define(\'WP_SITEURL\',$protocol.$name.$relpath);
    define(\'FS_CHMOD_DIR\',(02755&~umask())); //FOR CASE A
    define(\'FS_CHMOD_FILE\',(0664&~umask())); //FOR CASE A
    define(\'FS_CHMOD_DIR\',(02775&~umask())); //FOR CASE B
    define(\'FS_CHMOD_FILE\',(0664&~umask())); //FOR CASE B
    define(\'FS_METHOD\',\'ftpext\');
    define(\'FTP_BASE\',$abspath);
    define(\'FTP_HOST\',$addr);
    

  • 1 个回复
    最合适的回答,由SO网友:luukvhoudt 整理而成

    是啊!我终于找到了解决办法!

    诀窍是将所有文件和文件夹的所有权和组设置为apache用户。确保您有一个临时存储目录,并且需要../wp-content/upgrade/ 目录。比你的wp-config.php 这是我唯一不知道它的兼容性。但你需要持续的FS_METHOD 设置为direct 就像“死亡医生”建议的那样。

    为了让生活更简单,我创建了一个bash脚本,它非常容易使用,它将使所有内容都到位,除了wp-config.php 您必须自己将以下内容添加到此文件中。

    // Some static information, so fill this in correctly.
    $root=\'public_html\';
    define(\'FTP_USER\',\'<username>\');
    define(\'FTP_PASS\',\'<password>\');
    
    // This is dynamically configured. You won\'t have to edit.
    $addr=$_SERVER[\'SERVER_ADDR\'];
    $name=$_SERVER[\'SERVER_NAME\'];
    $host=$_SERVER[\'HTTP_HOST\'];
    $https=$_SERVER[\'HTTPS\'];
    $protocol=(!empty($https)&&$https!==\'off\'||$_SERVER[\'SERVER_PORT\']===443)?\'https://\':\'http://\';
    $abspath=(strpos(getcwd(),\'/wp-admin\')!==FALSE)?substr(getcwd(),0,strrpos(getcwd(),\'/wp-admin\')):getcwd();
    $relpath=substr($abspath,strrpos($abspath,$root)+strlen($root));
    $tmppath=substr($abspath,0,-(strlen($relpath)+strlen($root))).\'tmp\';
    define(\'WP_HOME\',$protocol.$host.$relpath);
    define(\'WP_SITEURL\',$protocol.$name.$relpath);  
    define(\'FS_CHMOD_DIR\',(02755&~umask()));
    define(\'FS_CHMOD_FILE\',(0644&~umask()));
    define(\'WP_TEMP_DIR\', $tmppath);
    define(\'FS_METHOD\',\'direct\');
    define(\'FTP_BASE\',$abspath);
    define(\'FTP_HOST\',$addr);
    
    与bash脚本相比,它的工作原理如下:bash脚本。上海$1 $2

    • $1: 选择要运行的操作帮助:显示如何使用此脚本
  • $2: 公共目录名,因此我们可以从何处检测文件是私有的。默认也是最常见的是public_html 如果服务器也使用此参数作为默认值,请将此参数保留为空
  • 现在是bash脚本本身!:D

    # If requested install WP
    if [ "$1" = new ]; then
        wget https://wordpress.org/latest.tar.gz
        tar -xvf latest.tar.gz
        mv -f wordpress/* .
        rm -rf wordpress/ latest.tar.gz
    fi
    if [[ "$1" = help || -z "$1" ]]; then
        echo "Usage: install.sh \\$1 \\$2"
        echo "\\$1: default=config, new=install new WP."
        echo "\\$2: default=public_html, *=root folder (must be a parent)."
    else
        # Define root directory
        if [ ! -z "$2" ]; then
            root=$2
        else 
            root=\'public_html\'
        fi
    
        # Define root path
        dir=`pwd -P`
        tmp=${dir%%$root*}"tmp"
    
        # Define apache user
        APACHE_USER=$(ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk \'END {if ($1) print $1}\')
    
        # Create missing directories
        if [ ! -d "$tmp" ]; then
            mkdir "$tmp"
            chown -R "$APACHE_USER":"$APACHE_USER" "$tmp"
        fi
        if [ ! -d wp-content/upgrade ]; then
            mkdir -p wp-content/upgrade
        fi
    
        # Setup group and ownership for the installation
        chown -R "$APACHE_USER":"$APACHE_USER" wp-* index.php xmlrpc.php .htaccess
    
        # Make sure the chmoding is correct
        find wp-* index.php xmlrpc.php .htaccess -type f -exec chmod 644 {} \\;
        find wp-* -type d -exec chmod 755 {} \\;
    
        # Remove unwanted WP files
        rm -f license.txt readme.html
    fi
    
    TIP: 要使其在系统中的任何位置都可用,只需将其放入/usr/local/bin/即可运行$ <script name> **$1 $2**. 确保“脚本名称”是唯一的。

    结束

    相关推荐

    Updates for a private plugin?

    如果我写一个私有插件,有没有办法使用WordPress自动更新机制来更新它 我想封装这个功能,但它是我自己的5个博客特有的,所以它不是公共插件资源的好候选。但我喜欢这种简单的更新机制 有没有办法做到这一点