1. 程式人生 > >原始碼nginx+php 7.0+mysql搭建WordPress

原始碼nginx+php 7.0+mysql搭建WordPress

worker_processes  auto;

error_log  logs/error.log;
error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    brotli on;  
    brotli_static off;  
    brotli_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/javascript text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;  
    brotli_buffers 4 16k;  
    brotli_comp_level 9;  
    brotli_window 512k;  
    brotli_min_length 512;

    gzip  on;
    server {
        listen       80;
        server_name  192.168.24.101;

        #charset koi8-r;
        
        gzip  on;
        gzip_types  text/plain text/css application/xml application/javascript;
        gzip_comp_level 6;        
        
        access_log  logs/host.access.log  main;
        root  /home/wwwroot/wordpress;
        index index.html index.htm index.php;
        
        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        # Add trailing slash to */wp-admin requests.
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
            include        fastcgi_params;
            fastcgi_param  HTTPS              off;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }


    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  192.168.24.101;

        ssl_certificate      server.crt;
        ssl_certificate_key  server.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        add_header           Front-End-Https on;

        access_log  logs/ssl.access.log  main;
        root  /home/wwwroot/wordpress;
        index index.html index.htm index.php;
        include wordpress.conf;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

         location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
            include        fastcgi_params;
        }

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    }

}
其中該配置檔案支援https,對於https支援谷歌壓縮演算法brotli,配置檔案裡面有server.crt和server.key,這參考http://blog.csdn.net/chen_jianjian/article/details/51131033成SSL證書。