23

I've got nginx 0.7x + PHP-FPM running under PHP 5.2.10 on one RHEL5 server, but trying to duplicate that setup under the bundled-in PHP-FPM in PHP 5.3.3 on a second server, I'm having some trouble with permission errors every time there's a GET.

FPM is started, and confirmed that fastcgi is listening on 9000, but each time I do a GET, I see this error in the nginx log:

2010/08/12 23:38:53 [crit] 5019#0: *5 stat() "/home/noisepages/www/" failed (13: Permission denied), client: 24.215.173.141, server: dev.noisepages.com, request: "GET / HTTP/1.1", host: "dev.noisepages.com"

Barebones nginx.conf.default works, at least. Here's my nginx.conf

server {
        listen       80;
        server_name  dev.noisepages.com;
        root   /home/noisepages/www;
        index  index.html index.htm index.php;

        access_log  logs/dev.access.log;
 error_log logs/dev.error.log;

        location / {

 if (-f $request_filename) {
  expires 30d;
  break;
  }

 # this sends all non-existing file or directory requests to index.php
 rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;
 if (!-e $request_filename) {
     rewrite ^.+?(/wp-.*) $1 last;
  rewrite ^.+?(/.*\.php)$ $1 last;
  rewrite ^ /index.php last;
  }
        }

        location ~ \.php$ {
            include        fastcgi_params;
            fastcgi_pass   unix:/dev/shm/php-fastcgi.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME    /home/dev/www/$fastcgi_script_name;
        }
    }

(The extra rewrite directives are for the use of WordPress multisite aka WordPress MU)

I've also verified that user www-data is declared not only in nginx.conf but also in php-fpm.conf for user and group values.

Maybe I'm not understanding what causes the error 13 message? Oddly enough, I'd tried to set up dev.noisepages.com on the first server in parallel to a couple of other virtual hosts -- each of which was working fine - and got the same error.

Peter Kirn
  • 333
  • 1
  • 2
  • 5

4 Answers4

60

You need to ensure you have +x on all of the directories in the path leading to the site's root - so /home, /home/noisepages and /home/noisepages/www

techraf
  • 4,163
  • 8
  • 27
  • 44
bear
  • 736
  • 5
  • 4
  • 2
    Yes, in fact www had the correct permissions but not the whole path! Thanks! Makes sense - dumb mistake on my part. – Peter Kirn Aug 13 '10 at 22:53
7

make sure /home/dev has correct permissions

chmod +x /home/dev
Mike
  • 21,910
  • 7
  • 55
  • 79
2

I had issues with permissions in php-fpm as well, in particular with php sessions. It turned out I just had to modify the user that php-fpm uses to run processes, since by default it was set to "nobody" user.

tutorial on it here: http://www.duchnik.com/tutorials/setting-up-php-with-nginx/

Rob
  • 21
  • 1
2

I had a simlar problem which got me here. My solution (based on the picked answer) was do a

chown -R root:www-data /home/noisepages/www
chmod g+w -R /home/noisepages/www

Now it works fine :)

Scott Warren
  • 141
  • 5