Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've set up nginx and php on an ubuntu server 12.04. I have the following php file:

echo "Hello ";
echo passthru("cat /proc/meminfo");
echo "world. I am ";
echo passthru("whoami");   

This works completely fine when run from the command line, and php returns the text from /proc/meminfo. When run via nginx, however, I see this:

Hello world. I am www-data 

Clearly, passthru is working. However, I can't seem to read anything in /proc. The permissions on /proc is dr-xr-xr-x, and I have confirmed that the www-data user that nginx and php run as can access that directory. I've turned on the php logging, and there are no error messages related to this.


Edit: Safe mode is turned off.

share|improve this question
have you got error logging/reporting enabled? – symcbean Jul 31 '12 at 10:10
I do. But this isn't producing an error :( It's failing silently. I have confirmed that the error logging is working, though. – River Jul 31 '12 at 10:36
Is it perhaps running your stuff in a chrooted enviroment or something? That might explain why "whoami" works but not "cat /proc/meminfo". – David Tinker Jul 31 '12 at 19:37
hmmm, I'll have a look into that. A quick google doesn't seem to suggest that it's in any way a default setup, though :-/ – River Jul 31 '12 at 19:47
up vote 2 down vote accepted

So, we fixed this offline -- I'm putting this up here for the next person who has this issue:

We verified that using the full path to cat resolved the problem. There was no visible error because passthru doesn't capture stderr (and the error was a failure to find cat). The River then discovered that $PATH was being set to the wrong thing, and fixed it.

share|improve this answer
The init script for the php5 daemon was explicitly setting the path (a good thing), but leaving off /bin, which is where cat lives. – River Aug 1 '12 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.