本文介绍了1在stderr中发送的FastCGI:“主脚本未知".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用Nginx,但是我对Apache和Linux并不熟悉.我正在使用一个现有项目,并且每当尝试查看index.php时,都找不到404文件.

My first time using Nginx, but I am more than familiar with Apache and Linux. I am using an existing project and when ever I am trying to see the index.php I get a 404 File not found.

这是access.log条目:

Here is the access.log entry:

2013/06/19 16:23:23 [error] 2216#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.ordercloud.lh"

这是网站可用的文件:

server {
# Listening on port 80 without an IP address is only recommended if you are not running multiple v-hosts
    listen       80;
# Bind to the public IP bound to your domain
#listen 127.0.0.11:80;
# Specify this vhost's domain name
    server_name www.ordercloud.lh;
    root /home/willem/git/console/frontend/www;
    index index.php index.html index.htm;

# Specify log locations for current site
    access_log /var/log/access.log;
    error_log /var/log/error.log warn;

# Typically I create a restrictions.conf file that I then include across all of my vhosts
#include conf.d/restrictions.conf;
# I've included the content of my restrictions.conf in-line for this example

# BEGIN restrictions.conf
# Disable logging for favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

# Disable logging for robots.txt
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
# END restrictions.conf

# Typically I create a yiiframework.conf file that I then include across all of my yii vhosts
#include conf.d/yiiframework.conf;
# I've included the content of my yiiframework.conf in-line for this example

# BEGIN yiiframework.conf
# Block access to protected, framework, and nbproject (artifact from Netbeans)
    location ~ /(protected|framework|nbproject) {
        deny all;
        access_log off;
        log_not_found off;
    }

# Block access to theme-folder views directories
    location ~ /themes/\w+/views {
        deny all;
        access_log off;
        log_not_found off;
    }

# Attempt the uri, uri+/, then fall back to yii's index.php with args included
# Note: old examples use IF statements, which nginx considers evil, this approach is more widely supported
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
# END yiiframework.conf

# Tell browser to cache image files for 24 hours, do not log missing images
# I typically keep this after the yii rules, so that there is no conflict with content served by Yii
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires 24h;
        log_not_found off;
    }

# Block for processing PHP files
# Specifically matches URIs ending in .php
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_intercept_errors on;
# Fix for server variables that behave differently under nginx/php-fpm than typically expected
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Include the standard fastcgi_params file included with nginx
        include fastcgi_params;
        #fastcgi_param  PATH_INFO        $fastcgi_path_info;
        #fastcgi_index index.php;
# Override the SCRIPT_FILENAME variable set by fastcgi_params
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
# Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
        fastcgi_pass 127.0.0.1:9000;

    }
}

我的/home/willem/git/console由www-data:www-data拥有(我的Web用户运行php等),出于沮丧的原因,我已授予它777权限...

My /home/willem/git/console is owned by www-data:www-data (my web user running php etc) and I have given it 777 permissions out of frustration...

有人可以建议吗?

推荐答案

好吧,经过一天的努力,我发现了3件事

Ok, so 3 things I found after a day of struggling

  1. 由于某些原因,我已经在9000端口上运行了某些软件,所以我更改为9001
  2. 我的默认网站拦截了我的新网站,我再次没有明白为什么不这样做,但我只是取消了链接
  3. Nginx不会自动为站点创建符号链接-可用于已启用网站.
  1. For some reason I had already something running on port 9000 so Ichanged to 9001
  2. My default site was intercepting my new one, once again I don'tunder stand why since it shouldn't, but I just unlinked it
  3. Nginx doesn't automatically do the sym link for sites-available tosite-enabled.

希望这可以为某人省些麻烦!

Hope this saves someone some trouble!

这是服务器故障中的更详细的链接:

Here is a more detailed link in server fault: https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown/517207#517207

这篇关于1在stderr中发送的FastCGI:“主脚本未知".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 03:17