将多站点从 Apache-mod_php 迁移到 Nginx-php7.1-fpm

将多站点从 Apache-mod_php 迁移到 Nginx-php7.1-fpm

我需要一些帮助。

我最近决定迁移我的网站

  • 来自 Debian 8 + Apache 2.4 + mod_php + Varnish
  • 升级到 Debian 9 + Nginx + php7.1-fpm + Varnish

我确实成功迁移了单个 wordpress 安装,效果很好。接下来我尝试迁移多站点安装。

  • Blog1 和 Blog2 的前端页面均运行良好。
  • 但是网络管理员和站点管理页面出现 500 错误。

我使用了 WP Codex 的子域名配置,但实际上我在这两个博客上使用了一个不同的域名。

我尝试过的:

  • 将 php 内存限制增加到 128,将 wp-config 内存限制增加到 64
  • 从设置中排除 Varnish
  • 将 map {} 添加到 nginx conf 和 WP Codex 的 WPMU 规则中
  • 禁用插件和主题

该多站点的 WP-admin 仍然无法访问

1. nginx.conf

user                    www-data www-data;

worker_processes        auto;

error_log               /var/log/nginx/error.log;
pid                     /var/run/nginx.pid;

events {

    worker_connections              1024;

    multi_accept                    on;
}

http {

    include                         /etc/nginx/mime.types;
    default_type                    application/octet-stream;

    server_tokens off;

    sendfile                        on;

    sendfile_max_chunk  128k;


    tcp_nopush                      on;
    tcp_nodelay                     on;


    reset_timedout_connection       on;

    client_header_timeout           3;
    client_body_timeout             5;

    send_timeout                    3;


    client_header_buffer_size       2k;
    client_body_buffer_size         256k;

    client_max_body_size            12m;


    access_log                      off;


    include                         /etc/nginx/conf.d/*.conf;
}

2. 前端.conf

server {
    listen      443 ssl;
    server_name profispb.com www.profispb.com xn--e1ajhifc2d.xn--p1ai www.xn--e1ajhifc2d.xn--p1ai;


    keepalive_timeout               60 60;


    gzip                on;
    gzip_comp_level     1;
    gzip_min_length     512;
    gzip_buffers        8 64k;
    gzip_types text/plain;
    gzip_proxied        any;


    ssl_prefer_server_ciphers on;

    ssl_session_cache shared:TLS:2m;
    ssl_session_timeout 2m;


    ssl_certificate      XXXXXXXXXXXXXXXXXXXXXX(hidden);

    ssl_certificate_key  XXXXXXXXXXXXXXXXXXXXXX(hidden);


    #ssl_dhparam /etc/ssl/sslforfree/privkey.pem;


    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;

    ssl_ciphers XXXXXXXXXXXXXXXXXX(hidden)


    add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains';

    location / {

        proxy_pass      http://127.0.0.1:6081/;

        proxy_set_header    Host              $host;
        proxy_set_header    X-Real-IP         $remote_addr;
        proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto https;
        proxy_set_header    X-Forwarded-Port  443;
    }
}

3.Backend.conf

map $http_host $blogid {
    default               0;

    xn--e1ajhifc2d.xn--p1ai      1;
    profispb.com      2;
}    
server {

    server_name profispb.com www.profispb.com xn--e1ajhifc2d.xn--p1ai www.xn--e1ajhifc2d.xn--p1ai;


    listen 127.0.0.1:81;


    root /var/www/vetka/profispb.com;
    index index.php;


    gzip                on;
    gzip_comp_level     9;
    gzip_min_length     512;
    gzip_buffers        8 64k;
    gzip_types text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
    gzip_proxied        any;

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

    location ~ \.php$ {

        try_files $fastcgi_script_name =404;

        fastcgi_keep_conn on;
        include /etc/nginx/fastcgi_params;
        fastcgi_read_timeout            3600s;
        fastcgi_buffer_size             128k;
        fastcgi_buffers                 4 128k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
    }

    #WPMU Files
        location ~ ^/files/(.*)$ {
                try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
                access_log off; log_not_found off;      expires max;
        }

    #WPMU x-sendfile to avoid php readfile()
    location ^~ /blogs.dir {
        internal;
        alias /var/www/vetka/profispb.com/wp-content/blogs.dir;
        access_log off;     log_not_found off;      expires max;
    }


}

错误日志样本(重复)

2017/12/19 22:28:05 [error] 11039#11039: *6 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: [] operator not supported for strings in /var/www/vetka/profispb.com/wp-content/plugins/revslider/includes/framework/base-admin.class.php:71
Stack trace:
#0 /var/www/vetka/profispb.com/wp-content/plugins/revslider/admin/revslider-admin.class.php(552): RevSliderBaseAdmin::addMetaBox('Revolution Slid...', '', Array, NULL)
#1 /var/www/vetka/profispb.com/wp-content/plugins/revslider/admin/revslider-admin.class.php(73): RevSliderAdmin->addSliderMetaBox()
#2 /var/www/vetka/profispb.com/wp-content/plugins/revslider/admin/revslider-admin.class.php(44): RevSliderAdmin->init()
#3 /var/www/vetka/profispb.com/wp-content/plugins/revslider/revslider.php(165): RevSliderAdmin->__construct('/var/www/vetka/...')
#4 /var/www/vetka/profispb.com/wp-settings.php(305): include_once('/var/www/vetka/...')
#5 /var/www/vetka/profispb.com/wp-config.php(101): require_once('/var/www/vetka/...')
#6 /var/www/vetka/profispb.com/wp-load.php(37): require_once('/var/www/vetka/...')
#7 /var/www/" while reading response header from upstream, client: 127.0.0.1, server: profispb.com, request: "GET /wp-admin/ HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "xn--e1ajhifc2d.xn--p1ai", referrer: "https://xn--e1ajhifc2d.xn--p1ai/"

答案1

看来我解决了。Revolution slider 是导致这个问题的原因。尽管我确定我已通过重命名插件文件夹禁用了所有插件。

因此,重命名 /plugin/revslider 后,我设法登录。

相关内容