日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

參照nginx官方樣本重新配置Wordpress站點

 louis2010 2019-03-10

nginx官網(wǎng)提供了常用blog/cms等系統(tǒng)的示例配置文件。Wordpress的在這里

基礎(chǔ)的是這樣:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        location / {
                # This is cool because no php is touched for static content.
                # include the '?$args' part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                #NOTE: You should have 'cgi.fix_pathinfo = 0;' in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

后面還有一些多站共存之類的配置。

按照這個范本我對我自己的配置做了一些調(diào)整,試了一下完全可行,比原來的好用??磥碇皩ginx的配置還是不夠了解。

我自己的配置大致是這樣:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#禁止空主機頭訪問
server {
    listen       80 default_server;
    server_name _;
    return 500;
}
server {
    listen       80;
    server_name  youdomain.com www.yourdomain.com;
    #下面這條規(guī)定站點根目錄,再往下的配置就以此為根
    root /usr/share/nginx/siterootpath;
    index index.php;
    #charset koi8-r;
    #下面這句是訪問log,按需開關(guān)
    #access_log  /var/log/nginx/log/host.access.log  main;
    #favicon,站點的圖標,可以顯示在瀏覽器標題欄上,和robots.txt兩個都不需要log
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location =/robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    # 所有靜態(tài)文件都直通,解決了之前jpg等文件單獨設(shè)置直通的問題,另外還可以直接支持固定鏈接
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    
    #自定義404
    #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   /usr/share/nginx/html;
    }
    #對上傳目錄禁止執(zhí)行php,并阻止除圖片以外的任何文件類型
    location /wp-content/uploads/ {
        if ($request_filename !~* \.(jpg|jpeg|gif|png)$) {
             return 403;
        }
        location ~ .*\.(php)?$ {
           deny all;
        }
    }
    # php文件發(fā)送到php5-fpm,現(xiàn)在這一段不需要寫root目錄了
    #
    location ~ \.php$ {
        #檢查php文件是否真實存在,防止偽裝成jpg的php等
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
    #js css 圖片等文件最大化有效期,不記錄訪問
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多