0

After failing to get FastCGI to work with PHP I have installed the PHP-FPM service which is reported to work out of the box, however PHP files are downloading instead of executing.

This is what I have in the nginx.conf file:

server {
    listen 80;
    server_name  pubserver;
    root         /usr/share/nginx/html;
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        fastcgi_param  PATH_INFO $fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }
}

The command netstat -tulpn | grep :9000 displays this which suggests PHP-FPM is running:

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      1058/php-fpm.conf)
4

1 Answer 1

2

Finally managed to get it working. After checking the logs I noticed there were errors like this which indicated redirect cycles:

2012/06/02 09:48:30 [error] 1699#0: *14 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico"

So I thoroughly checked the nginx.conf file and found that this line:

include /etc/nginx/conf.d/*.conf;

was loading 3 other files, namely:

  • default.conf
  • ssl.conf
  • virtual.conf

After opening default.conf I noticed the following rules were already there:

server {
    listen 80;
    server_name  _;
    root         /usr/share/nginx/html/demo;
    index        index.php;

    location ~ \.php$ {
        include        /etc/nginx/fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;

    }
}

Probably because I installed nginx and PHP-FPM from the CentOS repository it came already configured. Apparently I rushed to configure the PHP service before testing if it was working.

You must log in to answer this question.

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