2016-08-03 91 views
0

我想创建一个简单的服务器块在我的本地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" 

感谢

+0

错误日志说什么?有可能无法访问套接字。另外,您的系统是否启用了SELinux? –

+0

我已经添加了请求的错误日志输出 – devoncrazylegs

回答

0

所以,看来,当我升级Ubuntu的它升级我的PHP版本PHP7和删除我的PHP5的包。我的conf文件仍然指向旧的PHP5版本,所以我只是将其添加到我的默认和必要的conf文件中:

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;