0

我遇到了Wordpress Multisite的问题。

该项目是WordPress Multisite with Subdomains,在同一个/根文件夹上运行。

  1. 多站点 #1https ://one.sub.domain.com
  2. 多站点 #2https ://two.sub.domain.com
  3. 多站点#3https ://three.sub.domain.com
  4. 主域https ://sub.domain.com

VPS 正在运行带有 VestaCP 的 Centos 7。我们将 NGINX 用于 Web 服务。项目通过 SSL (https://) 运行。

基本上每当我尝试访问主域网络仪表板https://sub.domain.com/wp-admin/network时,我都会收到重定向错误。

页面未正确重定向

我已经检查并排除了以下可能的问题:

  • 不是文件/文件夹权限问题(文件有0644和文件夹0755+ 它已分配给VestaCP用户名domain_user
  • 不是 WordPress 配置或数据库错误。
  • 所有nginxphp日志文件都是空的/没有显示错误。

我怀疑这是由于 nginxsubdomain.domain.ssl.conf配置文件中的问题,但我无法弄清楚究竟是什么。这是配置文件的内容 - 默认情况下是VestaCP Web 模板Wordpress2_rewrite

server {
    listen      37.201.93.62:443;
    server_name sub.domain.com one.sub.domain.com two.sub.domain three.sub.domain;
    root        /home/domain_user/web/sub.domain.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/sub.domain.com.log combined;
    access_log  /var/log/nginx/domains/sub.domain.com.bytes bytes;
    error_log   /var/log/nginx/domains/sub.domain.com.error.log error;

    ssl         on;
    ssl_certificate      /home/domain_user/conf/web/ssl.sub.domain.com.pem;
    ssl_certificate_key  /home/domain_user/conf/web/ssl.sub.domain.com.key;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;

        if (!-e $request_filename)
        {
            rewrite ^(.+)$ /index.php?q=$1 last;
        }

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9002;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/domain_user/web/sub.domain.com/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/domain_user/web/sub.domain.com/stats/;
        include /home/domain_user/web/sub.domain.com/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/domain_user/conf/web/nginx.sub.domain.com.conf*;
}

这适用于/wp-adminhovewer 而不是/wp-admin/networkURLS 这是配置wp-config.php文件内容:

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'dbname');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'pass');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'ARhaa6zreusFJ2VWkuP+l+v]&JEa3kQ|HUn4[|PA:E%k&B|J_mm-?s---&Hew0x7');
define('SECURE_AUTH_KEY',  '$23xN:I#`0vQDff_t5Ogk*--h,:^@-0>r6_#,eQL=bc(##uwO&+|i]I<7[KpB%.?');
define('LOGGED_IN_KEY',    '9c3qJwhQxx:`|gP^.Y6>d{.;(,95#x@fgHH~#/?>K_jie<iz$mgD1E y;!|Nr~LV');
define('NONCE_KEY',        '<8Dh+67o;Pg7m_=++wa!0G+~H$p#Fq|ytwA,fBu~e}9`P.m|;?2&-^wM@Rq~[=?<');
define('AUTH_SALT',        ')*YP~hQ]sRn0;^+ApMmj/$);<~?:>vHhc080or<}MRM$a4#%*CEkC//;~GAFzP^-');
define('SECURE_AUTH_SALT', 'uX|45M7~=xKJo`GIoE|:;A[Dl2Sg.Z?w^+HfgLMF3*f5`h*>MT] j7.% X_t6n{7');
define('LOGGED_IN_SALT',   'I!NZC^][EM-<+d_6j3G{l2-0ba16YEM-&z$|Y`8qM>/<M]GPz)::~b/|+xPigr?u');
define('NONCE_SALT',       '-Vw#PgM@)P|2+U_x]J! 4+F-IZpe+y@Z~W}({D lPOHTH8hq%=#mse.77Ziw@);{');


/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define('WP_MEMORY_LIMIT', '256M');

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'sub.domain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

define('ALLOW_UNFILTERED_UPLOADS', true);


define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )
{
    $_SERVER['HTTPS']       = 'on';
    $_SERVER['SERVER_PORT'] = 443;
}
/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

我已经仔细检查过 - 这个配置工作正常,不会引起任何问题。

在这一点上,我真的迷路了,无法弄清楚如何解决这个问题。每当我尝试访问https://sub.domain.com/wp-admin/network/update-core.php时,我都会被重定向到https://sub.domain.com/wp-admin/network并出现重定向错误: 在此处输入图像描述

我希望得到你的帮助!提前致谢。

[编辑]

我刚刚注意到在访问https://one.sub.domain.com仪表板并悬停网络链接时,它返回https://wp-admin/network/,这清楚地显示了 nginx 的错误配置。

[可能的问题和解决方案]

Soo 我再次调试,我wp-content/debug.log包含了这些行

[07-Jan-2019 23:55:19 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:19 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:19 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:19 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:19 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:20 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:20 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:20 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:20 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:20 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:21 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:21 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:21 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:21 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:21 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:22 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:22 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:22 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:22 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20
[07-Jan-2019 23:55:22 UTC] PHP Notice:  Trying to get property 'domain' of non-object in /home/domain_user/web/sub.domain.com/public_html/wp-admin/network/admin.php on line 20

/wp-admin/network/admin.php文件中我注释掉了line 20

$redirect_network_admin_request = 0 !== strcasecmp( $current_blog->domain, $current_site->domain ) || 0 !== strcasecmp( $current_blog->path, $current_site->path );

这解决了这个问题,但显然它会弄乱网络管理员请求重定向所以现在问题是 -如何正确解决这个问题?

4

0 回答 0