25

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.

4 Answers 4

63

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

1
  • 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, 2010 at 22:53
7

make sure /home/dev has correct permissions

chmod +x /home/dev
3

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 :)

2
  • But how can you do it if you use Chroot users ? When using chrooted users, the /home/user/www folder must be owned by the user, and it not works. Feb 7, 2014 at 9:41
  • Sorry, I don't know :( Feb 7, 2014 at 11:29
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/

2
  • 3
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Scott Pack
    Nov 18, 2012 at 5:03
  • 7
    The link is dead.. Jun 24, 2016 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .