title: connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory)
body: <p>On my vagrant box , centtos 7, i had installed php7.0.3 and nginx 1.9.12. the php config www.conf. this file in the /usr/local/php/etc/php-fpm.d/ directory, Its configuration like this</p>
  
  <pre><code>user = www
  group = www
  ;listen = /tmp/php-fpm.sock
  listen = 127.0.0.1:9000
  listen.owner = www
  listen.group = www
  </code></pre>
  
  <p>and the nginx config.  the file vm.demo.com.conf in the /usr/local/nginx/conf/vhost/ directory. Its configuration like this</p>
  
  <pre><code>server {
      listen       80;
      server_name vm.demo.com;
      index index.html index.htm index.php;
      root  /data/wwwroot/demo;
  
      location / {
          if (-f $request_filename/index.html){
              rewrite (.*) $1/index.html break;
          }
          if (-f $request_filename/index.php){
              rewrite (.*) $1/index.php;
          }
          if (!-f $request_filename){
              rewrite (.*) /index.php;
          }
      }
      location ~ .*\.(php|php5)?$ {
          #fastcgi_pass unix:/tmp/php-fpm.sock;
          fastcgi_pass 127.0.0.1:9000;
  
          fastcgi_index index.php;
          include fastcgi.conf;
      }
      access_log  logs/demo.log main;
  }
  </code></pre>
  
  <p>in the nginx conf, if i use fastcgi_pass 127.0.0.1:9000 and the php-fpm.conf listen 127.0.0.1:9000, They are working properly
  bug if i use the socket configuration: </p>
  
  <p>php www.conf     </p>
  
  <pre><code>user = www
  group = www
  listen = /tmp/php-fpm.sock
  listen.owner = www
  listen.group = www 
  </code></pre>
  
  <p>nginx vm.demo.com.conf </p>
  
  <pre><code>    location ~ .*\.(php|php5)?$ {
          fastcgi_pass unix:/tmp/php-fpm.sock;
          fastcgi_index index.php;
          include fastcgi.conf;
      }
  </code></pre>
  
  <p>the nginx show 502 Bad gateway.  in the nginx error.log show this.</p>
  
  <pre><code>2016/03/14 21:17:04 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while 
  connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1", 
  upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
  2016/03/14 21:17:04 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while 
  connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1", 
  upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
  2016/03/14 21:18:01 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while 
  connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1", 
  upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
  </code></pre>
  
  <p>when i check the /tmp/php-fpm.sock file, it's existing</p>
  
  <pre><code>[root@vbox1 vhost]# ll /tmp/php-fpm.sock 
  srw-rw---- 1 www www 0 Mar 14 21:06 /tmp/php-fpm.sock
  </code></pre>
  
  <p>this are php and nginx running status:</p>
  
  <pre><code>[root@vbox1 vhost]# systemctl status php-fpm.service
  ● php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/etc/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2016-03-14 21:06:27 CST; 42min ago
    Process: 4189 ExecStop=/bin/kill -SIGINT $MAINPID (code=exited, status=0/SUCCESS)
   Main PID: 4198 (php-fpm)
     CGroup: /system.slice/php-fpm.service
             ├─4198 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
             ├─4199 php-fpm: pool www
             └─4200 php-fpm: pool www
  
  Mar 14 21:06:27 vbox1 systemd[1]: Started The PHP FastCGI Process Manager.
  Mar 14 21:06:27 vbox1 systemd[1]: Starting The PHP FastCGI Process Manager...
  [root@vbox1 vhost]# systemctl status nginx.service
  ● nginx.service - nginx
     Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2016-03-14 21:06:35 CST; 42min ago
    Process: 4180 ExecStop=/usr/local/nginx/sbin/nginx -s quit (code=exited, status=0/SUCCESS)
    Process: 4206 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 4207 (nginx)
     CGroup: /system.slice/nginx.service
             ├─4207 nginx: master process /usr/local/nginx/sbin/nginx
             ├─4208 nginx: worker process
             └─4209 nginx: worker process
  
  Mar 14 21:06:35 vbox1 systemd[1]: Starting nginx...
  Mar 14 21:06:35 vbox1 systemd[1]: Started nginx.
  </code></pre>
  
  <p>Can someone help me? If anyone encountered the same problem</p>