# Nginx can't run php only 'PAGE NOT FOUND'

**URL:** <https://www.ruby-forum.com/t/nginx-cant-run-php-only-page-not-found/226717>\
**Category:** NGINX\
**Created:** [February 19, 2013, 11:13am UTC](https://www.ruby-forum.com/t/nginx-cant-run-php-only-page-not-found/226717 "2013-02-19T11:13:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leejaycoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/839c29/32.png) [@leejaycoke](https://www.ruby-forum.com/u/leejaycoke)\
**Post date:** [February 19, 2013, 11:13am UTC](https://www.ruby-forum.com/t/nginx-cant-run-php-only-page-not-found/226717/1 "2013-02-19T11:13:34Z")

</div>

I’m sorry for my English…

nginx has default html page it’s /usr/share/nginx/html.  
But I changed custom new path it’s /home/norrent/public\_html.

If I put php and html files in the original path, works well.  
But if I put php and html files in the custom path, only html files  
work.  
and php files show me up ‘Page Not Found’  
then nginx record error message

* * *

[error] 2478#0: \*19 FastCGI sent in stderr: “Primary script unknown”  
while  
reading response header from upstream,  
client: XX.XXX.XX.XXX, server: lo blah~blah~blah ~~~~~~~

* * *

I thins I seted some wrong configuration.  
please check this nginx.conf file;

* * *

/etc/nginx/nginx.conf

* * *

server {  
listen 80;  
server\_name localhost;  
root /home/norrent/public\_html;

```
    location / {
        index index.php index.html index.htm;
    }

    location ~ \.php$ {
        set $php_root /home/norrent/public_html;
        fastcgi_pass unix:/tmp/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 

```

$php\_root$fastcgi\_script\_name;  
include fastcgi\_params;  
}  
}

* * *

/etc/nginx/fastcgi\_params

* * *

fastcgi\_param QUERY\_STRING $query\_string;  
fastcgi\_param REQUEST\_METHOD $request\_method;  
fastcgi\_param CONTENT\_TYPE $content\_type;  
fastcgi\_param CONTENT\_LENGTH $content\_length;

fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
fastcgi\_param REQUEST\_URI $request\_uri;  
fastcgi\_param DOCUMENT\_URI $document\_uri;  
fastcgi\_param DOCUMENT\_ROOT $document\_root;  
fastcgi\_param SERVER\_PROTOCOL $server\_protocol;  
fastcgi\_param HTTPS $https if\_not\_empty;

fastcgi\_param GATEWAY\_INTERFACE CGI/1.1;  
fastcgi\_param SERVER\_SOFTWARE nginx/$nginx\_version;

fastcgi\_param REMOTE\_ADDR $remote\_addr;  
fastcgi\_param REMOTE\_PORT $remote\_port;  
fastcgi\_param SERVER\_ADDR $server\_addr;  
fastcgi\_param SERVER\_PORT $server\_port;  
fastcgi\_param SERVER\_NAME $server\_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi\_param REDIRECT\_STATUS 200;

Thank you for nginx and forum!

Posted at Nginx Forum:

> **[nginx can't run php only 'PAGE NOT FOUND'](https://forum.nginx.org/read.php?2,236323,236323#msg-236323)**
>
> I'm sorry for my English... nginx has default html page it's /usr/share/nginx/html. But I changed custom new path it's /home/norrent/public\_html. If I put php and html files in the original path, works well. But if I put php and html files in the...

---

<div class="post-metadata">

**Author:** ![leejaycoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/839c29/32.png) [@leejaycoke](https://www.ruby-forum.com/u/leejaycoke)\
**Post date:** [February 19, 2013, 11:24am UTC](https://www.ruby-forum.com/t/nginx-cant-run-php-only-page-not-found/226717/2 "2013-02-19T11:24:05Z")

</div>

On 19/02/13 23:13, leejaycoke wrote:

> I’m sorry for my English…
> 
> nginx has default html page it’s /usr/share/nginx/html.  
> But I changed custom new path it’s /home/norrent/public\_html.

did you restart nginx to enable the new config?

---

<div class="post-metadata">

**Author:** ![leejaycoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/839c29/32.png) [@leejaycoke](https://www.ruby-forum.com/u/leejaycoke)\
**Post date:** [February 19, 2013, 12:57pm UTC](https://www.ruby-forum.com/t/nginx-cant-run-php-only-page-not-found/226717/3 "2013-02-19T12:57:34Z")

</div>

Of course;  
because /usr/share/nginx/html workds well.

everytime I restart nginx service, after save config file.

Posted at Nginx Forum:

> **[Re: nginx can't run php only 'PAGE NOT FOUND'](https://forum.nginx.org/read.php?2,236323,236328#msg-236328)**
>
> I'm sorry for my English... nginx has default html page it's /usr/share/nginx/html. But I changed custom new path it's /home/norrent/public\_html. If I put php and html files in the original path, works well. But if I put php and html files in the...
