# Problem with fpm php (wrong script location!)

**URL:** <https://www.ruby-forum.com/t/problem-with-fpm-php-wrong-script-location/217309>\
**Category:** NGINX\
**Created:** [February 27, 2012, 8:39pm UTC](https://www.ruby-forum.com/t/problem-with-fpm-php-wrong-script-location/217309 "2012-02-27T20:39:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 27, 2012, 8:39pm UTC](https://www.ruby-forum.com/t/problem-with-fpm-php-wrong-script-location/217309/1 "2012-02-27T20:39:58Z")

</div>

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! 😃 ), 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:

> **[Problem with fpm php (wrong script location ?!)](https://forum.nginx.org/read.php?2,223072,223072#msg-223072)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![nginx\_dig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nginx\_dig](https://www.ruby-forum.com/u/nginx_dig)\
**Post date:** [February 27, 2012, 9:06pm UTC](https://www.ruby-forum.com/t/problem-with-fpm-php-wrong-script-location/217309/2 "2012-02-27T21:06:07Z")

</div>

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)

😕

Posted at Nginx Forum:

> **[Re: Problem with fpm php (wrong script location ?!)](https://forum.nginx.org/read.php?2,223072,223074#msg-223074)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![nginx\_dig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nginx\_dig](https://www.ruby-forum.com/u/nginx_dig)\
**Post date:** [February 27, 2012, 9:26pm UTC](https://www.ruby-forum.com/t/problem-with-fpm-php-wrong-script-location/217309/3 "2012-02-27T21:26:37Z")

</div>

> 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.

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#root)**
>
> This directive appeared in version 1.11.8.

Andrejs

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