在centos7上安装好了nginx、php、mariadb,几个服务已经正常运行,nginx欢迎页可以正常访问。  
[root@demo ~]# systemctl list-unit-files --type=service | grep enabled
//...
mariadb.service                               enabled 
mysql.service                                 enabled 
mysqld.service                                enabled 
nginx.service                                 enabled 
php-fpm.service                               enabled 
//...
 
问题: 
把php项目文件夹放上去,却不能访问,采用`127.0.0.1:9000`和`unix:/run/php-fpm.sock`两种配置方式都不行。
 
gnginx配置`/etc/nginx/conf.d/default.conf`如下: 
    location ~ \.php$ {
        root           /var/www/project/public;
        #fastcgi_pass   unix:/run/php-fpm.sock;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
 php的`/etc/php-fpm.d/www.conf`配置如下:
#listen = /run/php-fpm.sock
listen = 127.0.0.1:9000
 在nginx的错误日志`/var/log/nginx/error.log`中,两种方式有各自的错误:
//使用unix:/run/php-fpm.sock的时候错误:
connect() to unix:/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, upstream: "fastcgi://unix:/run/php-fpm.sock:"
  
//使用127.0.0.1:9000的时候错误:
connect() failed (111: Connection re fused) while connecting to upstream, upstream: "fastcgi://127.0.0.1:9000"
 什么原因呢?
 
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。