views:

71

answers:

2

I believe this is a permissions issue, but not sure how to fix it.

I have a php script -- mainscript.php -- that calls:

$scriptCall = "/usr/bin/php wrap_prep.php 2>&1 &";

When running mainscript.php, the wrap_prep.php never executes. However, when I log into my webserver as root and run php wrap_prep.php 2>&1 & it works fine.

I have set both scripts to owner and group to my apache user as well as 755 permissions.

I recently recompiled PHP to add a library (not sure if this has anything to do with the new issue).

Thanks for any insight.

D

A: 

First of all, you should simply output what exec() ing the command gives you. There should be an error message no matter what.

Second, the fact that you are in a PHP script does not necessarily mean that the user PHP runs under is allowed to call the PHP binary at /usr/bin/php. Can you try changing the rights of that?

If that doesn't help, check out which user your PHP script is running as exactly. As far as I know, posix_getuid() is the most accurate tool to find that out. Make sure the permissions you are setting are really identical with the users you set the rights for.

Oh and Thilo's comment above is the most obvious thing and should be checked out first :)

Pekka
Thanks for reply. I tried echo'ing the results of the exec. It returned an empty string.Trying the posix_getuid()... looks like that may be an issue. When I run from ssh my UID is either root or username. But when I call it from my webbrowser, the UID is 99.Perhaps that's where the prob lies.
Dan D
Can you check which user has the UID 99?
Pekka
Using posix_getpwuid(99) I get: Array ( [name] => nobody [passwd] => [uid] => 99 [gid] => 99 [gecos] => Nobody [dir] => / [shell] => /sbin/nologin ) 99
Dan D
Can you execute any other command through exec (e.g. a `ls`) and do you get any output?
Pekka
Dan D
I executed 'ls' btw.
Dan D
Can you do `sudo nobody php wrap_prep.php` as root? I don't know whether you can sudo as nobody but it's worth a try.
Pekka
Wow. Smart. Found I needed to make the log directory 777 since 'nobody' didn't have permissions as well as the directory of files that I was streaming from. Great work. Thanks for you help!
Dan D
You're welcome, nice that it worked out.
Pekka
Hadn't used the posix_getuid and getpwuid before. Nice little fcn's. Thanks again.
Dan D
A: 

I'd check to make sure your host hasn't disabled exec entirely. I believe phpinfo() tells you if it is.

ceejayoz
No disabled functions or safe mode. Thx though.
Dan D