剛安裝好Nginx+php服務后,測試phpinfo頁是否顯示正確,卻提示http 404錯誤
nginx的錯誤提示如下:
2019/08/14 11:25:27 [error] 119533#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.0.62, server: , request: "GET......
phpinfo.php文件
<?php phpinfo();
原因:
nginx和php的root根目錄未設置對,如果代碼都在同一目錄下,可在server{}下設置全局root,不用單獨在location{}里設置root root /main/web/www #另外/scripts 修改為 $document_root location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }