Permissions issue? Can't run "php cron.php" on production server

KevySaysBeNice

[H]ard|Gawd
Joined
Dec 7, 2001
Messages
1,452
Perhaps this would be better suited for the Programming subforum, but I think this might be more of a server configuration issue and less of a actual programing question.

I'm trying to figure out why a cronjob isn't running as i'd expect (it's a Magento cronjob for what it's worth), so I figured I'd try to run the scheduled task myself cutting out the "cron" part of the job, and I'm having problems.

so, I typed this:
Code:
php cron.php

And I get this error:
Code:
Warning: require(app/Mage.php): failed to open stream: Operation not permitted in

... which is basically saying that it failed at require(app/Mage.php); The thing is, I have a copy of the production server on our staging environment, and I'm able to run the same exact command in the same exact way, and it runs perfectly. So, I figured perhaps permissions for the "app" folder or the "Mage.php" file were off, but when I compared them, they turned out to be the same for both.

Code:
Production (doesn't work): drwxr-xr-x  6 prod1 nobody    4096 May 11 17:31 app/
Staging (DOES work):       drwxr-xr-x  6 stg2 nobody    4096 May 11 17:30 app/


Production (doesn't work): -rw-rw-rw-  1 prod1 nobody 24163 Jan 26 08:35 Mage.php
Staging (DOES work):       -rw-rw-rw-  1 stg2 nobody    24163 Jan 26 08:35 Mage.php

same same!

Also, I'm running both of these commands as a super user (su). I've also tried "sudo php cron.php" (just for fun, because why not I figured) with the same result.

So, does anybody have any ideas as to what might be happening?

Thanks in advance!
 
I'm now offering bonus points for help with this. I tried going through and changing ownership of the files/directories in question and am having the same result. I'm wondering if it's (totally ignorant here) the "group" that the php command runs from, or something?


Ninja edit: and also, mods, if you read this, perhaps this would be better suited in the programming forum after all?
 
uhhmmm what server would be nice to know. It simply actually looks like you can not open a file from within the php script which would mean the server is running most likely in safe mode(or what ever it was called with php , been a while). It basiclly prevents file system manipulation liek opening a file (stream). I am sure there is someone out there that can correct my explanation but that is what it comes down to :)
 
I think I've seen this before and it turned out to be my php include path. Make sure it includes whereever apps lives.
 
I think I've seen this before and it turned out to be my php include path. Make sure it includes whereever apps lives.

<newb question>How exactly would I do this? I mean, the weird thing is that the php command is executing, but as you saying that it's executing from a different relative path? Which is why it's can't find the require("app/Mage.php")? How would I go about telling it which path it is in? </newb question>

Again, Linux newb, server newb, so sorry for the stupid question!
 
it's setup in your php.ini. Create yourself a php file with the following in it:

Code:
phpinfo();

put it in the same place as your other script and run it (both servers). it's got lots of stuff in it so you'll probably want to pipe it to more or to a file so you can scroll through it. Dumping it to a file is probably simplest because it's output as html. Then load those files up in a browser and compare them.
 
On that last note, I believe there's separate .ini files, so make sure you modify / edit them appropriately.
 
OK, so these are a few of the things that are different between the two configurations (that seemed at all hopeful):

enable_dl (staging - on, production - off)

open_basedir (staging it's set to nothing, production it's set to /home/jjf:/usr/lib/php:/usr/local/lib/php:/tmp - note that jjf is the user/user folder we created for this hosting account in cPanel)

PATH (staging: /home/jjf:/usr/lib/php:/usr/local/lib/php:/tmp - produciton: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin)

loaded modules a number of differences here, but again the problem seems to be related to paths.
 
So my guess is this is related to "open_basedir", which from my understanding is likely set on the production server for security purpose to limit files that can be included (?? please correct me!).

Still not 100% sure how to "fix" this though, even if that is the case!
 
it could be open_basedir, it does some funny things sometimes. Where exactly does app/Mage.php live?
 
well, it lives in
Code:
/home/jjf/public_html/store/app/Mage.php

and the command I'm running is:
Code:
php cron.php
which I'm running from:
Code:
/home/jjf/public_html/store/
So, cron.php is here:
Code:
/home/jjf/public_html/store/cron.php

The staging server (directory wise) mirrors this setup exactly, FWIW, and I'm running the same commands from the same relative locations.

(thanks again for the help pcbird!)
 
the staging path doesn't happen to have a .: (period followed by colon) in it does it? It's gotta be a path issue.

Of course it could also be a safe_mode setting but I doubt it. In the phpinfo output there's 2 columns (local and master). Make sure the values you're checking are the local ones.

If you want you can PM me the php core chunks of the output from production and staging I can take a closer look at those settings. There's noting secret in there.
 
Back
Top