Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Can you post your configuration files? –  Lekensteyn Apr 10 '11 at 20:58
    
@lekensteyn thanks! turns out to be a silly mistake, I was testing PHP on a xxx.xx.xxx.xxx/index.php and didn't edit the default config file. –  Ashfame Apr 10 '11 at 21:50
add comment

2 Answers 2

up vote 2 down vote accepted

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;
    }
}
share|improve this answer
    
+1 note that if you are using virtual hosts, this php block seems to need to go inside the individual files (not in the defaults file) –  kfmfe04 May 12 '13 at 5:46
add comment

Checks:

  • Have you reloaded nginx after changing the configuration? You can do that with sudo service nginx reload.
  • Nginx sets headers which cause the browser to cache pages. Make sure you're not seeing the cached version of the PHP page by pressing Ctrl + F5 (Firefox). Alternatively, use curl or wget to verify that the problem is not caused by your browser. You'd better to follow the official sources on installing php-fpm on nginx.
share|improve this answer
    
yes, I have reloaded nginx and tried Force refresh too but still I can't figure out what's going wrong here –  Ashfame Apr 10 '11 at 19:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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