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
server {
    listen       8089;
    root         /var/www/wp/;
    index index.html index.php;

        location / {
            #rewrite ^/(.*)$ /index.php?__path__=/$1 last;
            try_files $uri $uri/ /index.php?$args;
        }
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;


        location ~ [^/]\.php(/|$) {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass unix:/run/php/php7.1-fpm.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

       location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                log_not_found off;
        }


}

要点笔记

/var/www/wp/则是wordpress的安装目录,注意读写权限 fastcgi_passPHP的新版本中要用unix:/run/php/php7.1-fpm.sock;的形式

踩过的坑

部署wordpress中文版,在界面上初始化后,所有的Web资源(js,css,image)都无法正常加载,安装英文版解决。