nginx: php-fastcgi running but php files not executing

Posted by Daniel on Server Fault See other posts from Server Fault or by Daniel
Published on 2012-06-01T16:25:30Z Indexed on 2012/06/01 16:42 UTC
Read the original article Hit count: 300

Filed under:
|
|
|
|

I have recently set up a nginx server with PHP running as FastCGI process. The server is running with HTML files however PHP files are downloading instead of displaying and PHP code is not processed.

This is what I have in nginx.conf:

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

The command netstat -tulpn | grep :9000 displays the following which indicates php-fastcgi is running and listening on port 9000:

tcp     0     0 127.0.0.1:9000       0.0.0.0:*      LISTEN      2663/php-cgi

If it's if any importance my server is running on CentOS 6 and I installed nginx and PHP using the repositories from The Fedora Project.

© Server Fault or respective owner

Related posts about linux

Related posts about php