2013-06-19 8 views
8

La mia prima volta che utilizzo Nginx, ma sono più che familiare con Apache e Linux. Sto usando un progetto esistente e quando mai sto cercando di vedere l'index.php ottengo un file 404 non trovato.1 FastCGI inviato in stderr: "Script primario sconosciuto"

Ecco l'entrata access.log:

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" 

E qui è il file-siti disponibili:

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; 

    } 
} 

mio /home/willem/git/console è di proprietà di www-data: www-data (My Web utente che esegue php, ecc.) e gli ho dato 777 permessi di frustrazione ...

Qualcuno può consigliare?

+0

che cosa è l'URL che si sta tentando di chiamare? –

+0

Mi sento come se le persone su serverfault fossero più adatte ad aiutare. –

+0

Imposta correttamente il log di accesso php-fpm. È importante% f è lì dentro, quindi puoi vedere il percorso dello script che sta tentando di eseguire. Prova questo: 'access.format ="% R -% u% t \ "% m% r% Q% q \"% s% f% {mili} d% {kilo} M% C %% "'. Quindi pubblica i risultati nella tua domanda. – Melvyn

risposta

5

Ok, quindi 3 cose che ho trovato dopo una giornata di lotta

  1. Per qualche ragione mi aveva già qualcosa in esecuzione sulla porta 9000 quindi ho cambiato a 9001
  2. Il mio sito predefinito è stato intercettando il mio nuovo , ancora una volta non ho capito perché non dovrebbe, ma l'ho appena scollegato
  3. Nginx non esegue automaticamente il collegamento simbolico per i siti, disponibile a abilitato al sito.

Spero che questo salvi qualcuno qualche problema!

Ecco un collegamento più dettagliato in colpa server: https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown/517207#517207

7

Questo messaggio dal server FastCGI di solito significa che lo SCRIPT_FILENAME che è stato dato non è stato trovato o inaccessibili come file sul suo filesystem.

permessi dei file su Checkout /home/willem/git/console/frontend/www/index.php

E '644?

e/home/Willem/git/console/frontend/www/

E '755?

+0

Si è verificato un errore di porta tra le altre cose, ma ho ottenuto ordinato grazie! – We0

+0

qual è il modo veloce per impostare ricorsivamente tutti i file e le directory? –

+0

risposta completa qui: https://superuser.com/a/91938 –

5

Nel caso qualcuno ha avuto lo stesso errore: nel mio caso il problema era la direttiva radice mancante all'interno del blocco posizione in nginx.conf, as explained in the Arch wiki

+0

Questo lo ha risolto per me, grazie! –

1

Non so come il $ document_root viene calcolato, ma ho risolto il problema , da davvero facendo in modo che la mia radice del documento è in/usr/share/nginx/solo wher cartella html esiste

0

"copione primario sconosciuto" è causato da contesto di sicurezza SELinux.

cliente ottiene la risposta

File not found.

errore nginx.log presenta il seguente messaggio di errore

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

quindi basta cambiare la sicurezza tipo contesto di cartella principale Web per httpd_sys_content_t

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




ci sono 3 utenti per config nginx/php-fpm

/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 

dall'utente 1 e user-2 non sono necessari per essere uguali.

per presa unix, user-1 deve essere lo stesso utente-3, come nginx fastcgi_pass deve aver lettura/scrittura sul socket unix.

altrimenti nginx otterrà 502 Gateway, e nginx error.log ha il seguente messaggio di errore

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

Problemi correlati