nginxをインストールしたばかりで、最初のサイトをセットアップしようとしています。php-fpmでnginxを使用しようとしています。nginxがインストールされています(IPにアクセスすると、デフォルトのWelcome to nginxページが表示されます)。
今、私は簡単なスクリプトを実行しようとしています:
<?php
phpinfo();
しかし、403 Forbiddenページにアクセスし続けます。私の仮想ホストのログには、次のような行がたくさんあります。
2012/05/18 01:29:45 [error] 4272#0: *1 access forbidden by rule, client: x.170.147.49, server: example.com, request: "GET / HTTP/1.1", host: "example.com"
ファイル/srv/www/test/index.php
の所有者はnginxです(777
ファイルを含む完全なパスを使用できないようにしました)。
私はnginxが実際にnginx/nginx
設定のユーザーとグループの下で実行されていることを確認しました。nginx.confでは、他の構成が邪魔にならないようにデフォルトの構成インクルードパスを変更しました(include /etc/nginx/sites-enabled/
)。
私が使用している設定は次のように見えます(他の設定(php-fpm / nginx.conf)が必要な場合はお知らせください):
server {
listen 80;
server_name example.com;
root /srv/www/test;
access_log /var/log/nginx/example-access.log;
error_log /var/log/nginx/example-error.log error;
location ~ /. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~* .(js|css|png|jpg|jpeg|gif|ico|xml|swf|flv|eot|ttf|woff|pdf|xls|htc)$ {
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
log_not_found off;
expires 360d;
}
location ~ /.ht {
deny all;
access_log off;
log_not_found off;
}
location ~ /. {
access_log off;
log_not_found off;
deny all;
}
location ~ ^/(index|frontend_dev|admin|staging).php($|/) {
#rewrite ^/(.*)/$ /$1 permanent;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
index index.php;
try_files $uri /index.php?$args;
}
}