0

So am new to nginx. On Ubuntu I installed nginx using "sudo apt-get install nginx" then installed php5-fpm sudo apt get install php5-fpm. I followed the steps at: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04 and got nginx to work fine with php5-fpm.

This is the relevant section from my nginx configure file to enable fastCGI proxying.

location ~ \.php$ {

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

That works perfectly and php files run how they are suppose to.

I then downloaded nginx-1.7.3.tar.gz and built if from source:

--configure --prefix=/usr/local/nginx-1.7.3 make sudo make install

So by now I would have two installation of nginx. The first one using apt-get install nginx and this one which was built from source. I can run each one differently sudo service nginx start runs the the apt-get install version and sudo /usr/local/nginx-1.7.3/sbin/nginx runs the version built from source.

To enable fastCGI proxying on the "built from source" version I figured it's the same as the first installation of nginx so the nginx.conf file's location block for fast cgi proxying is identical to the first one.

BUT

The version that was built from source seems to not be communicating with php5-fpm so I get the error:

An error occurred

Sorry, the page you are looking for is currently unavailable. Please try again later.

And the error log for nginx says:2014/08/03 01:31:24 [crit] 8566#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

Due to my lack of knowledge I suspect I'm doing something really stupid but I can't seem to figure it out. Why does the "built from source" version give that error when trying to connect to files ending with .php ?

  • 1
    Can you please post the owner information of /var/run/php5-fpm.sock (the output of ls -alh would be fine) and your whole nginx config in both cases? I guess the system nginx is running as www-data, and your self-built does not. The output of ps aux |grep nginx would be useful too. – zhenech Aug 3 '14 at 8:15
  • For ls -alh : srw-rw---- 1 www-data www-data 0 Aug 2 23:16 /var/run/php5-fpm.sock – Helloppl Aug 3 '14 at 19:45
1

As zhenech pointed out, you most likely have a problem with the owner/permissions on your socket-file (/var/run/php5-fpm.sock).

In your fpm-config (e.g. /etc/php5/fpm/pool.d/www.conf), try the following:

listen.owner = www-data
listen.group = www-data
listen.mode = 0660
  • My www.conf file already has that configuration. – Helloppl Aug 3 '14 at 19:56
0

PROBLEM SOLVED:

My /etc/nginx/nginx.conf which is the configuration for nginx dowloaded with sudo apt-get install nginx has the user set as user www-data; so it is able to communicate with php5-fpm while the nginx-1.7.3 built from source located at /usr/local/nginx-1.7.3/conf/nginx.conf has the user set to user nobody;.

By changing user nobody; to user www-data; it started to communicate with php-fpm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.