Nginx:config在升级后无效

时间:2016-03-29 10:19:31

标签: wordpress nginx

我将WordPress迁移到新的vps,并决定将Nginx升级到1.9; 原始配置适用于Nginx 1.4.6(Ubuntu存储库中的默认配置)

但我现有的配置停止工作,我找不到问题在哪里......

server {
        listen 80;
        server_name www.example.com;
        rewrite ^/(.*)$ https://example.com/$1 permanent;
}

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /home/user/www;
        index index.php index.html index.htm;

        gzip                on;
        gzip_comp_level     1;

        server_name example.com;

        if ($http_x_forwarded_proto = "http") {
                return 301 https://$server_name$request_uri;
        }

        location ~ /\. {
                deny all;
        }

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

升级的想法,就是使用http2来访问这个网站

我使用的是Ubuntu 14.04和CloudFlare SSL

1 个答案:

答案 0 :(得分:0)

请遵循:http://opensourceeducation.net/updating-nginx-1-4-6-to-1-8-x-on-ubuntu-14-04-and-fixing-limit_zone-errors/

要解决此问题,我们将使用以下命令

打开NGINX.conf文件
  

vi /etc/nginx/nginx.conf

#######Add below line
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
######disable below limit_zone & limit_cone parameters
##limit_zone slimits $binary_remote_addr 5m;
##limit_conn slimits 5;

在NGINX中打开以下文件默认网站以修复WordPress中的空白屏幕错误

  

vi / etc / nginx / sites-enabled / default

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock; ##if you're using php5-fpm
fastcgi_index index.php;
include fastcgi_params;
##Add below line to fix the blank screen error
include fastcgi.conf;
}



root@www:~# /etc/init.d/nginx restart
 * Restarting nginx nginx
 ...done.