0

MY OS: Ubuntu 12.10 Web サーバー環境: Nginx + PHP-FPM

このチュートリアルに基づいてインストール

ここにウェブサイトのnginx confファイルがあります

server {
set $host_path "path_to_website";

server_name  website.local;

root $host_path;
set $yii_bootstrap "index.php";

charset utf-8;
index index.php index.html;

log_not_found off;

location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /$yii_bootstrap?$args;
    }

    location ~ ^/(protected|framework|themes/\w+/views) {
    deny  all;
    }

    #avoid processing of calls to unexisting static files by yii
    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    try_files $uri =404;
}


location ~ \.php$ {
    fastcgi_split_path_info  ^(.+\.php)(.*)$;
    #let yii catch the calls to unexising PHP files
    set $fsn /$yii_bootstrap;
    if (-f $document_root$fastcgi_script_name){
        set $fsn $fastcgi_script_name;
    }
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny  all;
}

}

ところで、この構成はYii フレームワーク用に最適化されています

問題は、Web サイトにアクセスしようとすると、次のエラーが発生することです。

File not found. 

そしてnginxerror.logファイルを開くと、次の内容が表示されます

    2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_websiteindex.php" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [error] 14388#0: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "website.local"

私はウェブサイトのパスについて100%確信しており、ホストファイルにも追加されていますwebsite.local。またchown、ウェブサイトが配置されている親ディレクトリ全体を再帰的に再帰的に編集しました。

何が問題なのかわかりません。この問題を解決するのを手伝ってください。助けたい人には誰にでもリモートアクセスを与えることができます。

ノート

path_to_website自信を持って実際のパスをこれに置き換えました。それで全部です。本当の道がある

4

2 に答える 2

0
 set $host_path "path_to_website";

path_to_website が何であるかを定義する必要があります。

例: /var/www/

  1. ターミナルを開く

  2. リスト項目

  3. wwwディレクトリのルートに移動します
  4. 「pwd」と入力し、その結果が何であれ
  5. それを $host_path に入力します
于 2013-03-22T19:55:53.413 に答える
0

nginx ログ ファイルは決して嘘をつきません。「許可が拒否されました」エラーであると表示されている場合は、そうです。必要がある

  • このフォルダー自体「path_to_website」がユーザーwww-data(スクリーンショットに基づいてnginxを実行しているユーザー)に読み取り可能であることを確認してください。これを試す 1 つの方法は、ターミナルで次のコマンドを実行することです。

     sudo -u www-data ls path_to_website
    

www-dataまたは単に許可が拒否されているかどうかを確認します

   ls -la path_to_website

そのパスの許可情報を調査します。

  • ユーザー www-data が「path_to_website」の親フォルダーにアクセスできない可能性があります。たとえば、path_to_website が "/var/www/mysite/" の場合、"/var" または "/var/www" は www-data で読み取れない可能性があります。
于 2013-03-23T03:03:13.183 に答える