18

初めて Nginx を使用しますが、Apache と Linux には精通しています。既存のプロジェクトを使用していますが、index.php を見ようとすると、404 ファイルが見つかりません。

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"

サイトで利用可能なファイルは次のとおりです。

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(phpなどを実行している私のWebユーザー)によって所有されており、欲求不満から777のアクセス許可を与えています...

誰でもアドバイスできますか?

4

5 に答える 5

9

通常、fastcgi サーバーからのメッセージは、指定された SCRIPT_FILENAME が見つからないか、ファイル システム上のファイルとしてアクセスできないことを意味します。

/home/willem/git/console/frontend/www/index.php のチェックアウト ファイルのアクセス許可

644ですか?

そして /home/willem/git/console/frontend/www/

755ですか?

于 2014-01-04T13:09:10.650 に答える
6

では、1 日苦労して見つけた 3 つのこと

  1. 何らかの理由で、ポート 9000 で既に何かを実行していたので、9001 に変更しました
  2. デフォルトのサイトが新しいサイトをインターセプトしていました。また、そうすべきではないので理由がわかりませんが、リンクを解除しました
  3. Nginx は、site-available から site-enabled へのシンボリック リンクを自動的に行いません。

これが誰かのトラブルを救うことを願っています!

サーバー障害のより詳細なリンクは次のとおりです

于 2013-06-20T10:02:37.140 に答える
5

誰かが同じエラーを起こした場合: Arch wiki で説明されているように、私の場合、nginx.conf のロケーション ブロック内にルート ディレクティブがないことが問題でした。

于 2015-09-17T13:53:13.100 に答える
2

$document_root がどのように計算されるかはわかりませんが、ドキュメントルートが /usr/share/nginx/ ちょうど html フォルダーが存在する場所にあることを確認することで、問題を解決しました

于 2015-12-21T10:24:36.717 に答える