NginX is not executing PHP

Hi,
I have installed:
  • FreeBSD Release Name 8.3-RELEASE
  • nginx-1.2.7_1,1
  • php53-5.3.22
  • php53-extensions-1.6
  • libtool-2.4.2
NginX and php_fpm are enabled in the rc.conf and running I can see NginX welcome page and
Code:
bsd# netstat
Active UNIX domain sockets
Address Type Recv-Q Send-Q Inode Conn Refs  Nextref Addr
c49576b8 stream 0 0 c4a3ec90 0 0 0 /var/run/php-fpm.sock
Here is my /usr/local/etc/nginx/nginx.conf file:
Code:
user  nobody;
worker_processes  1;
error_log  /var/logs/nginx_error.log;
pid        /var/logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;
    # We define the virtual host here
    server {
        listen       80;
        server_name  localhost;
        access_log  /var/log/access.log  main;
        location / {
            root   /usr/local/www/nginx/;
            index  index.html index.htm index.php;
        }
    # Let nginx know how to handle PHP using fastcgi
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/www/nginx$fastcgi_script_name;
            include        fastcgi_params;
        }
        location ~ /\.ht {
            deny  all;
        }
    }
}
When I try to access PHP file from the browser
/usr/local/www/nginx/test.php
Code:
<?php
  phpinfo();
?>

I get this message:
Code:
An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.
Could you please help me to resolve my problem?
Thank you!
 
derekschrock said:
What about the nginx access and error logs and the permissions of the socket and www/ directory?

Now after I have played with /usr/local/etc/nginx/nginx.conf
I am getting
Code:
502 Bad Gateway
message.
The ee /var/log/nginx_error.log has following records.
Code:
2013/03/20 17:36:40 [error] 42251#0: *1 open() "/usr/local/www/nginx/favicon.ico" failed (2: No such file or directory), client: 192.168
2013/03/20 17:36:45 [error] 42251#0: *1 connect() to 127.0.0.1:9000 failed (61: Connection refused) while connecting to upstream, client
2013/03/20 17:36:45 [error] 42251#0: *1 open() "/usr/local/www/nginx/favicon.ico" failed (2: No such file or directory), client: 192.168
2013/03/20 17:38:20 [error] 42271#0: *1 connect() to 127.0.0.1:9000 failed (61: Connection refused) while connecting to upstream, client
 
Raikh said:
try
Code:
fastcgi_pass   unix:/var/run/php-fpm.sock;
instead of
Code:
fastcgi_pass   127.0.0.1:9000;

Thank you!
Code:
fastcgi_pass   unix:/var/run/php-fpm.sock;
This helped.
 
Back
Top