在stderr中发送的FastCGI:“主脚本未知”-Nginx和Silex

恩里克·贡萨尔维斯(HenriqueGonçalves)

我在部署Silex项目的服务器上收到此错误。

在这台服务器上,我已经有nginx将请求从传递/到运行在端口5000的Flask应用程序。

因此,在将新项目从我的存储库中拉到我之后,/var/www/newproject我试图配置nginx,以便http://xxx.xxx.xxx.xxx/newproject将根源连接到/var/www/newprojectSilex应用程序的请求

我已经在网上搜索过,发现的所有配置都不能解决我的问题。访问任何路由,返回404。

我的整个配置是这样的:

server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;

    access_log /var/log/myproject/nginx_access.log;
    error_log /var/log/myproject/nginx_error.log;

    proxy_connect_timeout 300s;
    proxy_read_timeout 300s;

    location /newproject {
        root /var/www;
        try_files $uri $uri/ =404;
        index index.php;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        #fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/newproject/index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
        #fastcgi_param SCRIPT_FILENAME /var/www/newproject$fastcgi_script_name;
        include fastcgi_params;
    }

    location / {
        root /opt/myproject;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://xxx.xxx.xxx.xxx:5000;
            break;
        }
    }
}

我在这里想念什么?

谢谢你。

更新:

尝试了一个新的配置(如下所示),现在访问http://xxx.xxx.xxx.xxx/newproject/SOME_PATH我有一个404。

open() "/var/www/newproject/SOME_PATH" failed (20: Not a directory)
open() "/var/www/newproject/index.php/SOME_PATH" failed (20: Not a directory)

location /newproject {
        root /var/www/;
        index index.php index.html index.htm;
        location ~ ^/newproject/(.+\.php)$ {
            try_files $uri =404;
            root /var/www/;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_param HTTPS off;
            fastcgi_index index.php;
            #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            #fastcgi_param SCRIPT_FILENAME $document_root/index.php;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
        }
        location ~* ^/newproject/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /var/www/;
        }

    }
恩里克·贡萨尔维斯(HenriqueGonçalves)

因此,按照此Nginx子文件夹的站点配置,我设法解决了我的问题

现在我的配置是:

server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;

    root /opt/myproject;

    access_log /var/log/myproject/nginx_access.log;
    error_log /var/log/myproject/nginx_error.log;

    proxy_connect_timeout 300s;
    proxy_read_timeout 300s;

    location /newproject {
        root /var/www;
        index index.php index.html index.htm;
        rewrite ^/newproject/(.*)$ /newproject/$1 break;
        try_files $uri $uri/ /newproject/index.php?q=$uri&$args;

        location ~ .*\.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }
    }

    location / {
        root /opt/myproject/;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://xxx.xxx.xxxx.xxx:5000;
            break;
        }
    }
}

由于newproject取决于myproject,因此我将它们的配置保存在相同的文件以及相同的nginx访问和错误日​​志文件中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何调试“在stderr中发送的FastCGI:从上游读取响应头时未知主脚本”并查找实际的错误消息?

来自分类Dev

错误28105#0:* 1从上游读取响应头时,stderr中发送了FastCGI:“主脚本未知”

来自分类Dev

另一个FastCGI主脚本未知错误(nginx,php5-fpm)

来自分类Dev

Nginx,proxy_pass和fastcgi / php

来自分类Dev

Nginx 错误:“主脚本未知”,我该如何解决?谢谢

来自分类Dev

Ngnix-在stderr中发送的FastCGI:“ PHP消息:PHP注意:未定义的变量

来自分类Dev

WebTestCase,Silex和$ _GET

来自分类Dev

使用NGINX运行C FastCGI脚本

来自分类Dev

Nginx和Node.js未知指令

来自分类Dev

Nginx和Node.js未知指令

来自分类Dev

如何在用户脚本中发送和检索跨域Ajax数据

来自分类Dev

Nginx和FastCGI下载PHP文件而不是处理它们

来自分类Dev

Nginx Rewrite和FastCGI-下载PHP文件

来自分类Dev

如何跟踪Nginx中发送的字节

来自分类Dev

“主脚本未知” PHP

来自分类Dev

Silex在带有HHVM的Nginx中运行

来自分类Dev

Bash脚本stderr和stdout

来自分类Dev

如何为使用fastcgi和perlbrew在Nginx上运行的Perl催化剂应用程序创建初始化脚本

来自分类Dev

在kryonet中发送和接收数组

来自分类Dev

在kryonet中发送和接收数组

来自分类Dev

在iMessage应用中发送和打开数据

来自分类Dev

无法在soapclient和https中发送请求

来自分类Dev

Silex FormServiceProvider和form.secret参数

来自分类Dev

Silex getBaseUrl和getBasePath为空

来自分类Dev

Silex:注册 Twig 和 SecurityServiceProvider 导致错误

来自分类Dev

使用certbot和nginx制作站点https的Shell脚本

来自分类Dev

在ssh脚本中发送密码

来自分类Dev

期望在Unix中发送未知次数的答案

来自分类Dev

Nginx + fastcgi多线程

Related 相关文章

热门标签

归档