2013-06-19 13 views
8

Lần đầu tiên tôi sử dụng Nginx, nhưng tôi quen hơn với Apache và Linux. Tôi đang sử dụng một dự án hiện có và khi nào tôi đang cố gắng để xem index.php tôi nhận được một tập tin 404 không tìm thấy.1 FastCGI được gửi trong tiêu bản: "Tập lệnh chính không xác định"

Đây là mục 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" 

Và đây là các sites-available file:

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; 

    } 
} 

My /home/willem/git/console thuộc sở hữu của www-data: www-data (web của tôi người dùng đang chạy php v.v.) và tôi đã cấp cho nó 777 quyền hạn của sự thất vọng ...

Ai cũng có thể tư vấn?

+0

whats URL mà bạn đang cố gắng gọi? –

+0

Tôi cảm thấy như những người ở serverfault sẽ phù hợp hơn để giúp đỡ. –

+0

Thiết lập nhật ký truy cập php-fpm chính xác. Điều quan trọng là% f nằm trong đó, vì vậy bạn có thể thấy đường dẫn kịch bản mà nó đang cố thực hiện. Hãy thử cái này: 'access.format ="% R -% u% t \ "% m% r% Q% q \"% s% f% {mili} d% {kilo} M% C %% "'. Sau đó đăng kết quả trong câu hỏi của bạn. – Melvyn

Trả lời

5

Ok, vậy 3 điều tôi tìm thấy sau một ngày vật lộn

  1. Đối với một số lý do tôi đã có một cái gì đó đang chạy trên cổng 9000 vì vậy tôi đổi thành 9001
  2. trang web mặc định của tôi đã chặn cái mới của tôi , một lần nữa tôi không dưới lý do vì nó không nên, nhưng tôi chỉ cần hủy liên kết nó
  3. Nginx không tự động liên kết sym cho các trang web khả dụng với kích hoạt trang web.

Hy vọng điều này sẽ giúp người khác gặp khó khăn!

Dưới đây là một liên kết chi tiết hơn trong lỗi server: https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown/517207#517207

7

Thông điệp đó từ máy chủ fastcgi thường có nghĩa là SCRIPT_FILENAME rằng nó đã được đưa ra đã không tìm thấy hoặc không thể tiếp cận như một tập tin trên hệ thống tập tin của nó.

quyền tập tin Checkout /home/willem/git/console/frontend/www/index.php

Có 644?

Và/home/willem/git/console/frontend/www/

Có phải là 755 không?

+0

Nó hóa ra là một lỗi cổng trong số những thứ khác, nhưng tôi đã nhận nó được sắp xếp cảm ơn! – We0

+0

cách nhanh chóng để đặt tất cả thư mục và tệp đệ quy là gì? –

+0

câu trả lời đầy đủ ở đây: https://superuser.com/a/91938 –

5

Trong trường hợp bất cứ ai có lỗi tương tự: trong trường hợp của tôi vấn đề là chỉ thị gốc mất tích bên trong khối vị trí trong nginx.conf, as explained in the Arch wiki

+0

Điều này đã giải quyết được cho tôi, cảm ơn! –

1

Tôi không biết làm thế nào $ DOCUMENT_ROOT được tính nhưng tôi giải quyết vấn đề , bởi thực sự đảm bảo rằng gốc tài liệu của tôi là tại/usr/share/nginx/chỉ wher thư mục html tồn tại

0

"kịch bản tiểu không rõ" là do bối cảnh an ninh SELinux.

khách hàng nhận được phản ứng

File not found.

lỗi nginx.log có thông báo lỗi sau

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

vì vậy chỉ cần thay đổi an ninh loại bối cảnh của thư mục web root để httpd_sys_content_t

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




có 3 người sử dụng cho cấu hình 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 

user- 1 và người dùng-2 không cần thiết phải giống nhau.

cho unix socket, sử dụng 1 cần phải được giống như người dùng 3, như nginx fastcgi_pass phải đọc/ghi cho phép trên các ổ cắm unix.

khác nginx sẽ nhận được 502 Bad Cổng và nginx error.log có thông báo lỗi sau

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

Các vấn đề liên quan