Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Edit: I've posted the question with my own answer on Ask Ubuntu. I'm leaving this open for now, but if someone sees the need to close it, that's fine.

I'm trying to set up a freshly installed Ubuntu (12.04) server, but I can't get PHP files running through php-fpm. No matter what I do, I always get a "Access denied." page (plain text, not html or anything).

Installed packages:

nginx
nginx-common
nginx-full
php5
php5-cli
php5-common
php5-fpm

Configuration details:

PHP-FPM:

user = www-data
group = www-data
listen = /var/run/php5-fpm.sock

Nginx:

user www-data;
worker_processes 3;
events { worker_connections 1024; }

Default/test domain:

server {
    listen       80;
    server_name  localhost;
    root         /extra/htdocs/default;
    index        index.html index.php

    access_log   /extra/logs/default/access.log;
    error_log    /extra/logs/default/error.log;

    location / {
        try_files  $uri $uri/ /index.html;
    }

    location ~ \.php
    {
        fastcgi_split_path_info  ^(.+\.php)(/.+)$;

        include fastcgi_params;

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

/extra/htdocs/default/index.php:

<?php
phpinfo();

Everything else is default. Both the Nginx and php-fpm logs show no errors. Yet when I load http://<server-ip>/index.php I get the "Access denied" page.

Troubleshooting:

  • The index.html file works just fine. Therefore it must be either php-fpm, or the fastcgi binding between Nginx and php-fpm.
  • I've set the ownership (both user and group) of the entire /extra directory to www-data, and ownership to 777, just to be sure (I'll tone it down once it works of course). So it's certainly not a permissions issue
  • It's not the security.limit_extensions issue that I see a lot: by default that is set to .php, which is exactly what I'm requesting. I've explicitly set it to .php .html, with the same result.

I'm really getting tired of this, I've installed this setup twice already (albeit on OSX machines), and everything worked flawlessly. Is there anything I'm overlooking?

Edit: as requested, the log contents:

The Nginx error log is empty.

Nginx access log (removed ip):

<ip> - - [17/Jul/2012:11:21:25 +0200] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11"
<ip> - - [17/Jul/2012:11:21:28 +0200] "GET /index.php HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11"
<ip> - - [17/Jul/2012:11:21:34 +0200] "-" 400 0 "-" "-"

php-fpm log:

[17-Jul-2012 10:44:14] NOTICE: fpm is running, pid 4969
[17-Jul-2012 10:44:14] NOTICE: ready to handle connections
share|improve this question
Could you add relevant lines from /extra/logs/default/access.log, /extra/logs/default/error.log and /var/log/php5-fpm.log. – snap Jul 17 '12 at 9:13
I've updated the question with log info. – Peter Kruithof Jul 17 '12 at 9:26
It's file permissions. nginx doesn't have permission to read or readdir something, probably /extra/htdocs/default/index.php. – womble Jul 17 '12 at 13:18
Please look at the 'troubleshooting' section. I've already stated that permissions are not the problem. This is backed by the fact that my html file is loading properly. – Peter Kruithof Jul 17 '12 at 14:11
Do not cross post on Stack Exchange sites. askubuntu.com/questions/164627/… – Chris S Jul 18 '12 at 1:59
show 2 more comments

closed as off topic by Chris S Jul 18 '12 at 1:59

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Could you take a look on line of nginx vhost:

 index        index.html index.php

it not finished with semicolon.

share|improve this answer
Good catch. Nginx would usually catch these errors too. Anyway, the correct answer is posted at AskUbuntu. – Pothi Kalimuthu Jul 18 '12 at 1:48

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