[英]Nginx PHP server block returning 502 error
我试图在本地Nginx安装上创建一个简单的服务器块,该服务器块将返回一个简单的PHP index.php页面。 我以前做过此事,没有任何问题,但在这种情况下,我似乎无法正常工作,也不知道为什么! 每当我尝试访问URL时,我都收到502错误。
这是我的本地主机文件:
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
这是我在/ etc / nginx / sites-available文件夹中的conf文件:
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文件中,我有一个简单的die语句,该语句应显示在访问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"
谢谢
因此,当我升级Ubuntu时,似乎将我的PHP版本升级到PHP7,并删除了我的PHP5软件包。 我的conf文件仍然指向旧的PHP5版本,因此我只是将其添加到默认的和必要的conf文件中:
fastcgi_pass Unix:/var/run/php/php7.0-fpm.sock;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.