20

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.

57

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

  • 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
  • 1
    If I could give you another 10 upvotes I would. – Tim Mar 7 '12 at 23:01
  • You are really cool! I spend 2 hours in google to find your answer! Thank you! – Serhii Polishchuk Oct 3 '15 at 18:46
  • Thanks so much! I was messing on a production server and I drowed in cold sweat when this happened...! – lephleg Feb 11 '17 at 5:37
5

make sure /home/dev has correct permissions

chmod +x /home/dev
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/

  • 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 '12 at 5:03
  • 3
    The link is dead.. – Christoph Bühler Jun 24 '16 at 8:28
1

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

  • 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. – Vincent LITUR Feb 7 '14 at 9:41
  • Sorry, I don't know :( – Scott Warren Feb 7 '14 at 11:29

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.