我想創建一個簡單的服務器塊在我的本地Nginx安裝,將返回一個簡單的PHP index.php頁面。我之前做過這些,沒有任何問題,但在這種情況下,我似乎無法使其工作,我不知道爲什麼!每當我嘗試訪問URL時,我都會收到502錯誤。Nginx的PHP服務器塊返回502錯誤
這裏是我的本地hosts文件:
127.0.0.1 localhost
127.0.1.1 james-ESPRIMO-P420
127.0.0.1 st-davids-lab.dev
127.0.0.1 molecare.dev
127.0.0.1 st-davids-ire.dev
127.0.0.1 charity-site.dev
127.0.0.1 smaxtec.dev
127.0.0.1 product-viewer.dev
127.0.0.1 stdavids-brain.dev
127.0.0.1 http://php-parser.dev
127.0.0.1 php-parser.dev
而且這裏距離我的conf文件在/ etc/nginx的/網站可用的文件夾:
server {
listen 80;
server_name php-parser.dev http://php-parser.dev;
root /var/www/php-parser/;
index index.php index.html;
# Important for VirtualBox
sendfile off;
location/{
try_files $uri $uri/ /index.php?$query_string;
#rewrite ^(.*)$ /index.php
}
location ~* \.php {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache off;
fastcgi_index index.php;
}
我也創建符號鏈接通過執行當前命令在啓用站點的文件夾中:
sudo ln -s /etc/nginx/sites-available/phpparser.conf /etc/nginx/sites-enabled
在我的/ var/www/php-parser/index.php文件我有一個簡單的死亡語句,應該顯示這是工作時,我訪問的URL php-parser.dev但這從來沒有得到擊中。
任何人都可以看到這裏出了什麼問題,因爲它是真氣!這將是一件愚蠢的事!
這裏是Nginx的錯誤日誌輸出:
2016/08/03 11:01:55 [crit] 4830#4830: *34 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: php-parser.dev, request: "GET/HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "php-parser.dev"
感謝
錯誤日誌說什麼?有可能無法訪問套接字。另外,您的系統是否啓用了SELinux? –
我已經添加了請求的錯誤日誌輸出 – devoncrazylegs