Problem with fpm php (wrong script location!)

Hi,

first of all: i am fairly new to nginx (used apache for several years
now)…
Works great, except fpm php…
In the last 24h i have read many tutorials, forum posts and howtos…

First there was no error message at all…just a blank page (many others
were getting that too).

Now after some changes i get an error message (horray! :smiley: ), but i have
no clue how to fix this.

2012/02/27 20:23:10 [error] 26226#0: *1 open()
“/usr/local/etc/nginx/html/info.php” failed (2: No such file or
directory), client

That is not the normal document root.

All normal (html ,text e.g.) files are beeing delivered just fine out of
my document root.
But why is he looking at another directory to geht this php script ?!

I tried many variants of " fastcgi_param SCRIPT_FILENAME
/websites/some.domain/http$fastcgi_script_name;"
even with document_root$fastcgi_script_name …

Nothing worked.
Any ideas ho to change the looking directory to the document root ? The
php.info is exisitng in there.

My relevant config data:

in my vhost config file:
########

server {
listen 256.256.256.256:80; #just an example ip
server_name .some.domain;

    location / {
        root   /websites/some.domain/http;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/local/www/nginx-dist;
    }

    location ~ /\.ht {
        deny  all;
    }

location ~ .php$ {
root html;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/websites/some.domain/http$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;

  if (-f $request_filename) {
    # Only throw it at PHP-FPM if the file exists (prevents some PHP

exploits)
fastcgi_pass backend_php; # The upstream determined
above
}

}
}

in nginx.conf:

user www www;
worker_processes 1;

main server error log

error_log /var/log/nginx/error.log ;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

main server config

http {
server_names_hash_bucket_size 64;
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;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;

server {
listen 256.256.256.256:80 default;
server_name _;
access_log /var/log/nginx/access.log main;

server_name_in_redirect off;

      location / {
            index index.html;
            root  /usr/local/www/nginx;
       }

}

# virtual hosting
include /usr/local/etc/nginx/vhosts/*;

upstream backend_php {
server 127.0.0.1:9000;
}

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223072,223072#msg-223072

Just another addition:

I tried to set the root parameter again to an absolut value…
No i am getting an empty page again when calling the php script.

(access log shows a normal 200)

:confused:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223072,223074#msg-223074

location / {
root /websites/some.domain/http;
index index.php index.html index.htm;
}

Try to move this main root out of location / {} block to the server {}
block:

server {

server_name …;
root …;

}

Also, root should ALWAYS point to an absolute path.

http://nginx.org/en/docs/http/ngx_http_core_module.html#root

Andrejs

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223072,223077#msg-223077

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs