2013-06-19 18 views
8

Mein erstes Mal mit Nginx, aber ich bin mehr als vertraut mit Apache und Linux. Ich verwende ein vorhandenes Projekt und wenn ich versuche, die index.php zu sehen, bekomme ich eine 404 Datei nicht gefunden.1 FastCGI gesendet stderr: "Primäres Skript unbekannt"

Hier ist der access.log Eintrag:

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" 

Und hier ist die sites-available-Datei:

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; 

    } 
} 

Meine /home/willem/git/console von www-data ist: www-data (meine Web Benutzer läuft php etc) und ich habe es 777 Berechtigungen aus Frustration gegeben ...

Kann jemand beraten?

+0

was ist die URL, die Sie anrufen möchten? –

+0

Ich fühle mich wie die Leute bei Serverfault wäre besser geeignet, um zu helfen. –

+0

Richten Sie das php-fpm-Zugriffsprotokoll korrekt ein. Es ist wichtig, dass% f da ist, damit Sie den Skriptpfad sehen können, den es auszuführen versucht. Versuchen Sie folgendes: 'access.format ="% R -% u% t "% m% r% Q% q"% s% f% {mili} d% {kilo} M% C %% ". Dann poste die Ergebnisse in deiner Frage. – Melvyn

Antwort

5

Ok, also 3 Dinge fand ich nach einem Tag der

  1. Aus irgendeinem Grund zu kämpfen hatte ich schon etwas läuft auf Port 9000 so ich auf 9001 geändert
  2. Meine Standard-Site wurde meine neue abfängt , wieder einmal ich nicht unter Grund, warum, da es nicht sollte, aber ich gerade es
  3. Nginx löste nicht automatisch die sym-Link für Websites-verfügbar Site-aktiviert.

Hoffe, das spart jemandem einige Probleme! Hier

ist eine detailliertere Verbindung in Serverfehler: https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown/517207#517207

7

Diese Botschaft vom fastcgi Server in der Regel bedeutet, dass die SCRIPT_FILENAME, dass es gegeben wurde, wurde nicht gefunden oder unzugänglich als Datei auf ihrem Dateisystem.

Kasse Dateiberechtigungen auf /home/willem/git/console/frontend/www/index.php

Ist es 644?

und/home/willem/git/console/Frontend/www/

Ist es 755?

+0

Es stellte sich unter anderem heraus, dass es sich um einen Port-Fehler handelte, aber ich habe es sortiert, danke! – We0

+0

was ist eine schnelle Möglichkeit, alle Verzeichnisse und Dateien rekursiv zu setzen? –

+0

vollständige Antwort hier: https://superuser.com/a/91938 –

5

Falls jemand hatten den gleichen Fehler: in meinem Fall das Problem die fehlende Stamm Richtlinie innerhalb des Standorts Block in nginx.conf, as explained in the Arch wiki

wissen war
+0

Dies löste es für mich, danke! –

1

ich nicht, wie der $ document_root berechnet wird, aber ich das Problem gelöst von wirklich dafür sorgen, dass mein Dokument root/usr/share/nginx/nur wher der html-Ordner

0

"Primary Skript unbekannt" wird verursacht durch SELinux Sicherheitskontext vorhanden sind.

Client die Antwort

File not found.

nginx Fehler.Protokoll hat die folgende Fehlermeldung

*19 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

so nur Sicherheitskontext Ordnertyp Web-Root zu httpd_sys_content_t

chcon -R -t httpd_sys_content_t /var/www/show




es ändern sind 3 Benutzer für nginx/php-fpm Config

/etc/nginx/nginx.conf

user nobody nobody; ### `user-1`, this is the user run nginx woker process 
... 
include servers/*.conf; 

/etc/nginx/servers/www.conf

location ~ \.php$ { 
# fastcgi_pass 127.0.0.1:9000; # tcp socket 
    fastcgi_pass unix:/var/run/php-fpm/fpm-www.sock; # unix socket 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 

/etc/php-fpm.d/www.conf

[www] 
user = apache ### `user-2`, this is the user run php-fpm pool process 
user = apache 

;listen = 127.0.0.1:9000 # tcp socket 
listen = /var/run/php-fpm/fpm-www.sock # unix socket 

listen.onwer = nobody ### `user-3`, this is the user for unix socket, like /var/run/php-fpm/fpm-www.sock 
listen.group = nobody # for tcp socket, these lines can be commented 
listen.mode = 0660 

benutzer- 1 und Benutzer 2 müssen nicht identisch sein.

für Unix-Socket, haben die gleichen wie Benutzer-3, wie nginx fastcgi_pass seinen benutzer 1 Bedarf/Schreibberechtigung auf der Unix-Socket lesen muss.

sonst nginx wird 502 Bad Gateway, erhalten und nginx error.log die folgende Fehlermeldung hat

*36 connect() to unix:/var/run/php-fpm/fpm-www.sock failed (13: Permission denied) while connecting to upstream