php - 子目录中带有 FastCGI 和 WordPress 的 NginX - "No input file specified"

标签 php wordpress nginx fastcgi

我正在尝试将 WordPress 博客迁移到我网站的子目录(即 example.com/blog/)。使用 NginX 和 FastCGI,我已经设法让整个 WordPress 站点在端口 8080 上工作,但是当我尝试应用规则将其放置在/blog 中时,我得到“未指定输入文件”

我认为因为我可以让 PHP 和 WordPress 正常工作,所以我可以假设我的安装或相关文件夹的权限没有问题。

这是我的虚拟主机的样子(我在“/”运行一个 Rails 站点):

    server {
    listen       80;
    server_name  example.com localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location /blog/ {
        root /home/deploy/www/blog.example.com/html;
        index index.php;
        try_files $uri $uri/ /blog/index.php;
    }

    location ~ \.php$ {
        root /home/deploy/www/blog.example.com/html;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location / {
        root   /home/deploy/www/example.com/public;
        passenger_enabled on;
        index  index.html index.htm;
    }

我也试过这个配置得到同样的结果:

    location ~ ^/blog/.*(\.php)?$ {
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           root   /home/deploy/www/blog.example.com/html;
           try_files $uri =404;
    #        fastcgi_split_path_info ^(/blog/.+\.php)(.*)$;

            #fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #       fastcgi_intercept_errors on;
          fastcgi_pass 127.0.0.1:9000;
    }

我做错了什么?

最佳答案

您是否将 WordPress 与多站点一起使用?

我不清楚您的设置,但是此列表中的教程肯定会对您有所帮助:http://rtcamp.com/wordpress-nginx/tutorial

如果你能分享更多细节,我可以更好地指导你。

8080 从何而来?你在 Apache 中使用 Nginx 吗??

“未指定输入文件”看起来像是与 PHP 文件的错误位置相关的错误...

尝试改变

在这里输入代码fastcgi_index index.php;

try_files index.php blog/index.php

假设“博客”是您移动 WordPress 的文件夹。

关于php - 子目录中带有 FastCGI 和 WordPress 的 NginX - "No input file specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12335822/

相关文章:

php - 将文本文件导入MySQL php程序

php - 重置Wordpress 'next User ID'号码

php - Wordpress Rest API 不适用于 Postman

nginx add_header Set-Cookie 过期不起作用

mysql - 将 SSL 证书添加到 mysql docker 容器

nginx proxy_pass和URL解码

php - 分号中断 mysql_query

php - 从另一个 php 文件调用一个 php 文件,该文件在 echo 中具有 html 表单?

php - 如何使用 PHP 确保 MySQL DB 表中值的唯一性 – 唯一键用例?

javascript - 在引导轮播上单击下一个或上一个时图像跳转