phpを実行しようとすると、nginx上でAccess deniedになります。いろいろ検索すると、default.confの設定を見直しなさいというのがたくさん出てきたのですが、どれを試してもアクセス拒否になってしまいます。
どのあたりを改善すべきでしょうか?
/etc/nginx/conf.d/default.conf↓
php
1server { 2 listen 8001 default_server; 3 root /usr/share/nginx/html; 4 index index.html index.htm; 5 server_name localhost; 6 7 location / { 8# First attempt to serve request as file, then 9# as directory, then fall back to displaying a 404. 10 try_files $uri $uri/ /index.html; 11# Uncomment to enable naxsi on this location 12# include /etc/nginx/naxsi.rules 13 } 14 15 location /doc/ { 16 alias /usr/share/doc/; 17 autoindex on; 18 allow 127.0.0.1; 19 allow ::1; 20 deny all; 21 } 22 23 error_page 500 502 503 504 /50x.html; 24 location = /50x.html { 25 root /usr/share/nginx/html; 26 } 27 28 location ~ \.php$ { 29 try_files $uri =404; 30 fastcgi_split_path_info ^(.+\.php)(/.+)$; 31# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 32 33# With php5-cgi alone: 34#fastcgi_pass 127.0.0.1:9000; 35# With php5-fpm: 36fastcgi_pass unix:/var/run/php5-fpm.sock; 37 fastcgi_index index.php; 38 include fastcgi_params; 39 fastcgi_param PATH_INFO $fastcgi_path_info; 40 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 41 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 } 43 location ~ /\.ht { 44 deny all; 45 } 46} 47
なお、ディストリビューションはUbuntu14.04で、php5-fpmは起動しており、実行しようとしているphpファイルの実行権限は755です。/usr/share/nginx/html上のhmtlファイルはブラウザ上で実行できております。
/etc/php5/fpm/php.ini↓
gi.fix_pathinfo=0
/var/log/nginx/error.log↓
FastCGI sent in stderr: "Access to the script '/usr/share/nginx/html' has been denied (se e security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /h ello.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost:8001"
追記:/etc/php5/fpm/pool.d/www.conf
PHP
1user = www-data↲ 2group = www-data↲ 3listen = /var/run/php5-fpm.sock↲ 4pm = dynamic↲ 5pm.max_children = 5↲ 6pm.start_servers = 2↲ 7pm.min_spare_servers = 1↲ 8pm.max_spare_servers = 3↲ 9
回答2件
あなたの回答
tips
プレビュー