wordpress + nginx + rest api

Nginx Config

server {
        listen   443;

        root /xxx/zhuchengliang;
        index index.php index.html index.htm;
        server_name  47.240.77.142 zhuchengliang.com www.zhuchengliang.com;

        ssl on;
        ssl_certificate /xxx/certificates/xxx_zhuchengliang.com.pem;
        ssl_certificate_key /xxx/certificates/xxx_zhuchengliang.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ALL:!ADH:xxxxxH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers on;

        location / {
                try_files $uri $uri/ /;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }   
            
        location ~ .php$ {
                try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}   

重要

设置下固定链接地址:

https://github.com/WP-API/WP-API/issues/2561

然后测试下rest api:

https://zhuchengliang.com/wp-json/

https://zhuchengliang.com/wp-json/wp/v2/posts

1 Response

  1. zclmoon说道:

    /etc/nginx
    /var/logs/nginx

发表评论

电子邮件地址不会被公开。 必填项已用*标注