Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

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

Suggestions?

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.