NGINX Webサーバーにindex.phpとinfo.phpを表示しようとしていますが、何らかの理由で機能させることができません。ブラウザーがファイルを表示せずにダウンロードし続けます。私はたくさんのチュートリアルを試しましたが、何が悪いのかわかりません。
OS:Ubuntu17.10サーバー
PHPバージョン:7.1
cgi.fix_pathinfoが0に設定されている
de cgi.fix_pathinfoを除いて、www.confファイルがデフォルトです。
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name nginx1.domain.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
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/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
#location ~ /\.ht {
# deny all;
#}
}
誰か助けてくれませんか?
この小さな例を試してください。
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
そして、php-fpmが実行されているかどうかを再確認してください。
sudo systemctl status php7.1-fpm.service
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加