▼やりたいこと
nginxでphpを動かしたい。
▼環境
Vagrantでバーチャルサーバー構築
Ubuntu16.04
Nginx1.10.1
PHP 7.0
PHP-FPM 7.0
▼nginxの設定
/etc/nginx/conf.d/default.conf
server { listen 80; server_name 192.168.33.10; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { # root /var/www/html; fastcgi_pass unix:/run/php/php7.0-fpm.sock; # fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
▼nginxエラーログ
2016/10/08 13:50:49 [error] 21977#21977: *1 open() "/var/www/html/50x.html" failed (2: No such file or directory), client: 192.168.33.1, server: 192.168.33.10, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock", host: "192.168.33.10"
▼index.phpの置き場所は以下
/var/www/html/index/php
index.phpはuser,groupともにwww-data
問題なく表示されるindex.htmlもwww-data:www-data
-rwxr-xr-x 1 www-data www-data 537 May 31 14:16 50.html -rwxr-xr-x 1 www-data www-data 612 May 31 14:16 index.html -rwxr-xr-x 1 www-data www-data 18 Oct 8 12:22 index.php -rwxr-xr-x 1 www-data www-data 6 Oct 8 12:06 info.php
phpはどうすれば表示されますでしょうか。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/09 09:23
2016/10/09 10:50 編集
2016/10/10 04:22
2016/10/10 04:37 編集