Ubuntu – php does not parse using nginx & phpfm

nginxPHP

I am setting up a VPS and followed the nginx, PHP, MySQL instructions for WordPress from this tutorial http://tutspundit.com/howto-install-nginx-php-fpm-mysql-php533-wordpress-ubuntu-part-1/ and then http://tutspundit.com/how-to-install-nginx-php-fpm-mysql-php533-wordpress-part-2/

The problem is the php file returns the php code itself in the browser without parsing it. So what did I miss?

Update: Staring phpfpm or nginx works fine but I think nginx isn't aware of phpfm at all, some link is missing perhaps? I checked nginx error logs but there is nothing related to php. I can't seem to figure out what is missing.

Best Answer

Turns out to be a silly mistake of not editing the default config file to proxy PHP request.

server {
    listen   80;
    server_name domain.in;
    access_log /home/ashfame/www/domain.in/logs/access.log;
    error_log /home/ashfame/www/domain.in/logs/error.log;

    location / {
        root   /home/ashfame/www/domain.in/public_html;
        index  index.html index.php;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/ashfame/www/domain.in/public_html$fastcgi_script_name;
    }
}
Related Question