【问题标题】:how to config wordpress in nginx?如何在 nginx 中配置 wordpress?
【发布时间】:2019-12-02 06:51:24
【问题描述】:

伙计们, 我有 3 个位置的服务器,

我像这样配置我的 nginx:

server {
    listen 80;
    listen [::]:80;


    server_name www.zavie.co zavie.co 81.91.147.131;

    location / {
            root /home/zavie/zavieco/zavie;

            index index.php coming-soon.html index.htm index.nginx-debian.html;


    }
    location /word {
            index index.php index.html index.htm;
            root /home/zavie/zavieco/word;
             fastcgi_pass unix:/run/php/php7.2-fpm.sock;

    }
    location ~ /phpmyadmin {

            alias /home/zavie/zavieco/phpmyadmin;
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            include snippets/fastcgi-php.conf;
    }
    location /static/ {
            root /home/zavie/zavieco/zavie360/zavie360;
    }
     location /zavie360 {

            alias /home/zavie/zavieco/zavie360;
}
}

但是当我打开 zavie.co/word 时,它不会打开 wordpress,我该如何配置呢?

【问题讨论】:

  • 也许 wordpress.stackexchange.com 会是一个更好的网站?

标签: wordpress ubuntu nginx server


【解决方案1】:

除非您在 /home/zavie/zavieco/word/word 下安装了 WordPress,否则您对 root 指令使用了错误的值。详情请见this document

您的 location /word 块无法提供 WordPress 的静态资产。

使用这样的东西:

location ^~ /word {
    root /home/zavie/zavieco;
    index index.php;

    try_files $uri $uri/ /word/index.php;

    location ~ \.php$ {
        try_files $uri =404;

        include fastcgi_params;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
    }
}

详情请见this document

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-23
    • 2021-08-14
    • 2016-11-03
    • 1970-01-01
    • 2019-11-17
    • 2013-01-20
    相关资源
    最近更新 更多