# Php-fpm works with some sites but not others?

**URL:** <https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097>\
**Category:** NGINX\
**Created:** [May 28, 2012, 6:08pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097 "2012-05-28T18:08:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 28, 2012, 6:08pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/1 "2012-05-28T18:08:49Z")

</div>

This is a weird one, and I’m turning to the mailing list as a last  
resort  
after searching for a few hours to no avail. Our server hosts a number  
of  
websites, each with an individual nginx config file. We recently had to  
replace the hdd, so I backed everything up and reinstalled on the new  
hardware. I got php-fpm running again and started to add back sites.  
Everything was working perfectly, until for some reason one site just  
failed to show anything.

I made sure the permissions were correct, and the nginx config file  
hasn’t  
changed. One bizarre thing is that a call to phpinfo() returns “File not  
found”, but I can’t seem to find a fix for this online. It also doesn’t  
explain why phpinfo() works perfectly on about 4 other sites. Has anyone  
come across this error before?

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:11pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/2 "2012-05-28T18:11:19Z")

</div>

On Mon, May 28, 2012 at 11:07 PM, Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I made sure the permissions were correct, and the nginx config file hasn’t  
> changed. One bizarre thing is that a call to phpinfo() returns “File not  
> found”, but I can’t seem to find a fix for this online. It also doesn’t  
> explain why phpinfo() works perfectly on about 4 other sites. Has anyone  
> come across this error before?

Yes.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:15pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/3 "2012-05-28T18:15:02Z")

</div>

Was kinda hoping for a solution…lol.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:19pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/4 "2012-05-28T18:19:24Z")

</div>

On Mon, May 28, 2012 at 11:13 PM, Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Was kinda hoping for a solution…lol.

Fix the config.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:32pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/5 "2012-05-28T18:32:26Z")

</div>

On Mon, May 28, 2012 at 11:22 PM, Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Seriously? You think I haven’t tried that? My issue is that the config  
> _works_ for some sites, and then fails for another. There are no differences  
> between the config files other than the names used. This was all working  
> before on my other server, and all I did was copy the files across.
> 
> So which part of the config do you think I need to fix?

Too bad I don’t have clairvoyance therefore I can’t help you on this  
one.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:37pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/6 "2012-05-28T18:37:24Z")

</div>

You said you’ve seen the error before. What was causing it that time? Do  
you want me to send a copy of my config, if so, which one? You don’t  
have  
to be clairvoyant; just tell me which files you need to look at.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:23pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/7 "2012-05-28T18:23:47Z")

</div>

Seriously? You think I haven’t tried that? My issue is that the config  
_works_ for some sites, and then fails for another. There are no  
differences between the config files other than the names used. This was  
all working before on my other server, and all I did was copy the files  
across.

So which part of the config do you think I need to fix?

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:49pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/8 "2012-05-28T18:49:52Z")

</div>

On Mon, May 28, 2012 at 11:36 PM, Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You said you’ve seen the error before. What was causing it that time?

Many times, ranges from incorrect file permission, incorrect service  
privilege, incorrect root, incorrect alias, incorrect rewrite,  
incorrect try\_files, incorrect location, incorrect variable, bug, etc.

Not sure if that helps.

> Do you  
> want me to send a copy of my config, if so, which one? You don’t have to  
> be clairvoyant; just tell me which files you need to look at.

I don’t even know how you set up your config… (one instance per  
host? One file per host? One “set” file per host? One big file?)

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 7:03pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/9 "2012-05-28T19:03:30Z")

</div>

On Mon, May 28, 2012 at 11:53 PM, Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> All permissions look correct to me.

# sudo -u php\_user cat /path/to/problematic/file.php

> I very much doubt it is something wrong  
> with an alias / rewrite / try\_files since this is the same config that only  
> a few hours ago was working perfectly well on the old install. What doesn’t  
> help is that there don’t appear to be any errors in the logs (i.e. nginx  
> logs just log 404’s rather than PHP errors, and the php-fpm error log has  
> just startup info, despite me turning error reporting on to the maximum).

Because that’s the error when php can’t find specified input file.  
It’s never logged iirc.

> server\_names, etc).

“only”… “etc”. Ok.

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 6:54pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/10 "2012-05-28T18:54:49Z")

</div>

On Mon, May 28, 2012 at 5:48 PM, Edho A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Many times, ranges from incorrect file permission, incorrect service  
> privilege, incorrect root, incorrect alias, incorrect rewrite,  
> incorrect try\_files, incorrect location, incorrect variable, bug, etc.
> 
> Not sure if that helps.

All permissions look correct to me. I very much doubt it is something  
wrong  
with an alias / rewrite / try\_files since this is the same config that  
only  
a few hours ago was working perfectly well on the old install. What  
doesn’t  
help is that there don’t appear to be any errors in the logs (i.e. nginx  
logs just log 404’s rather than PHP errors, and the php-fpm error log  
has  
just startup info, despite me turning error reporting on to the  
maximum).

> I don’t even know how you set up your config… (one instance per  
> host? One file per host? One “set” file per host? One big file?)

/etc/nginx/sites-available/ ← Individual config file per host.  
/etc/nginx/sites-enabled/ ← Symbolic links to sites-available.

PHP is working perfectly on 3 other sites, and one of those sites has an  
almost identical config file (only thing changed are the names /  
server\_names, etc).

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 10:23pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/11 "2012-05-28T22:23:27Z")

</div>

-------- Original-Nachricht --------

> Datum: Mon, 28 May 2012 17:53:48 +0100  
> Von: Adrian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Betreff: Re: php-fpm works with some sites but not others?

> All permissions look correct to me. I very much doubt it is something
> 
> > I don’t even know how you set up your config… (one instance per  
> > host? One file per host? One “set” file per host? One big file?)
> 
> /etc/nginx/sites-available/ ← Individual config file per host.  
> /etc/nginx/sites-enabled/ ← Symbolic links to sites-available.
> 
> PHP is working perfectly on 3 other sites, and one of those sites has an  
> almost identical config file (only thing changed are the names /  
> server\_names, etc).

If you are so super confident that everything is okay with the files  
then I would suggest you to do this.

Assume you have host1, host2, host3 and host4. The one not working is  
host4 while host1 to host3 work.

Now go on and edit the configuration for host4 and just change the  
document root to point to one of the other hosts (aka host1 or host2 or  
host3). I know, I know. This will break host4 but host4 is anyway not  
working (according to your statement). So after reloading nginx go into  
a browser and check if host4 is now working (showing the content of the  
other selected host). If this is the case then it is not the nginx  
configuration.

> –  
> Adrian H.

–  
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir  
belohnen Sie mit bis zu 50,- Euro! [https://freundschaftswerbung.gmx.de](https://freundschaftswerbung.gmx.de)

---

<div class="post-metadata">

**Author:** ![Adrian\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Adrian\_H](https://www.ruby-forum.com/u/Adrian_H)\
**Post date:** [May 28, 2012, 8:14pm UTC](https://www.ruby-forum.com/t/php-fpm-works-with-some-sites-but-not-others/220097/12 "2012-05-28T20:14:14Z")

</div>

On Mon, May 28, 2012 at 05:07:46PM +0100, Adrian H. wrote:

Hi there,

> Everything was working perfectly, until for some reason one site just  
> failed to show anything.
> 
> I made sure the permissions were correct, and the nginx config file hasn’t  
> changed. One bizarre thing is that a call to phpinfo() returns “File not  
> found”, but I can’t seem to find a fix for this online.

A frequent response from nginx for a “broken” php setup is “HTTP/1.1  
404 Not Found”, with a header indicating “X-Powered-By: PHP”, and a body  
content of “No input file specified.”

A frequent reason for this is that the SCRIPT\_FILENAME fastcgi param  
sent by nginx to the fastcgi server does not identify a file that the  
fastcgi server is able to access.

(Different fastcgi servers may use different param names to identify  
the file.)

If you examine your nginx config for the server and location which  
handles  
a working request, you may be able to determine what SCRIPT\_FILENAME is  
set to. Do the same for the server and location of a failing request,  
and you may see the relevant difference.

Alternatively, if you enable the debug log, you’ll see something like

fastcgi param: “SCRIPT\_FILENAME: /usr/local/nginx/html/php”

which will show you exactly what it is set to for your requests (as well  
as all of the other params that are set).

Maybe that will help you spot the difference between a working request  
and a failing one.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
