0

ラップトップでWebサーバーとしてapache2を実行していましたが、nginxに移行することにしました。

-Apacheを削除せずにnginx-php(fastcgi-fpm)をインストール

- /etc/nginx/site-enabled/default を次のルールで構成

root /var/www;
index index.html index.htm index.php;

    location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    deny all;
}
location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

    # With php5-cgi alone:
    fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

ブラウザーから localhost と入力すると、403 禁止で応答します

127.0.0.1:9000 と入力しています この Web ページは利用できません

12.0.0.1 禁止

権限の問題が表示されますが、表示Webサイトを実行するときにchmod 777 var/wwwおよびapache2を実行します

では、構成の何が問題なのか、何が欠けているのでしょうか?

4

1 に答える 1

0

上記がデフォルトファイルの唯一のコンテンツである場合、なぜnginxが起動しているのか疑問に思っています。サーバー ブロックを作成する必要があります。

server {
  listen 80;
  server_name _;
  root /var/www;
  index index.html index.htm index.php;

  location /doc/ {
    alias /usr/share/doc;
    autoindex on;
    allow 127.0.0.1;
    deny all;
  }

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
  }
}

nginx -t(再)起動する前に、常に設定を確認してください。

于 2013-06-19T09:20:59.920 に答える