command line and ABSOLUTE_SCRIPT_PATH
I've had phpdig up and running on my site for a while, but I've gotten tired of manully spidering, so I decided to look into setting up cron -- which largely appears to be really easy, bravo!
The problem I'm running into is that php spits out a bunch of include warnings when I try to run from the command line... I've no idea why, though I'm pretty sure I've got it set up properly. My config.php looks like: define('ABSOLUTE_SCRIPT_PATH','/Library/WebServer/Documents/tools/phpdig'); if ((!isset($relative_script_path)) || (($relative_script_path != ".") && ($relative_script_path != "tools/phpdig") && ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH))) My search.php isn't located in my phpdig directory, obviously. Anyway, these settings have everything on the website working well. But when I try the following from the command line [yep, I know php's in a slightly unusual place]: /usr/local/php/bin/php -f /Library/WebServer/Documents/tools/phpdig/admin/spider.php http://www.mydomain.com I get the following output: PHP Warning: main(../includes/config.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 91 PHP Warning: main(): Failed opening '../includes/config.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 91 PHP Notice: Use of undefined constant USE_RENICE_COMMAND - assumed 'USE_RENICE_COMMAND' in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 93 PHP Warning: main(../admin/robot_functions.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 112 PHP Warning: main(): Failed opening '../admin/robot_functions.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 112 PHP Fatal error: Call to undefined function: phpdigprnmsg() in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 128 Which seem like the kind of messages I might get if I had ABSOLUTE_SCRIPT_PATH incorrectly set. But I've looked at it a million times and retyped it and I swear it's correct. Any idea what I'm doing wrong here? Thanks for your help. |
The output is saying that PHP cannot find various files for inclusion WRT this location:
Code:
/Library/WebServer/Documents/tools/phpdig/admin/spider.php PHP Code:
|
whoops
Okay, so you got me... I was actually trying to obscure a little bit the actual path I'm using (just paranoia on my part about disclosing full directory structures). Made the change in what I posted as config but not in the php warnings. But the cat's out of the bag, so I might was well confess... *actual* config.php:
define('ABSOLUTE_SCRIPT_PATH','/Library/WebServer/Documents/tools/phpdig'); if ((!isset($relative_script_path)) || (($relative_script_path != ".") && ($relative_script_path != "tools/phpdig") && ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH))) And *actual* command I'm using is: /usr/local/php/bin/php -f /Library/WebServer/Documents/tools/phpdig/admin/spider.php http://www.mydomain.com Sorry to be misleading and by doing so waste anyone's time. I'm an idiot. |
OIC, ha ha, anyway... where are the config.php and robot_functions.php files relative to the following:
Code:
/Library/WebServer/Documents/tools/phpdig/admin/spider.php |
The usual...
/Library/WebServer/Documents/tools/phpdig/admin/spider.php /Library/WebServer/Documents/tools/phpdig/includes/config.php /Library/WebServer/Documents/tools/phpdig/admin/robot_functions.php So they seem so to be where they're supposed to be... |
Are you sure "/Library/WebServer/..." is the full path? Maybe you have something like "/dir1/dir2/Library/WebServer/..." for the full path? Try the following script. Does it echo "/Library/WebServer/..." or something else?
PHP Code:
|
Yep, I'm pretty darn sure (I'm basically co-sysadmin for the machine, so I know the dir structure pretty well). The above script outputs:
/Library/WebServer/Documents /Library/WebServer/Documents/tools/phpdig/test.php /Library/WebServer/Documents/tools/phpdig/test.php |
The only other thing I can think of is that it's a permission/ownership/group issue, where it runs from the web interface but not from shell. Check that the PhpDig files have "-rw-r--r--" permission and see if /usr/local/php/bin/php is set with "-rwxr-xr-x" permission. The crontab executable can have "-rws--x--x" permission.
Also, I did think about the php.ini file, perhaps changing: Code:
include_path = .:/usr/local/php/lib/php Code:
include_path = ./:/usr/local/php/lib/php:/Library/WebServer/Documents/tools/phpdig/admin:/Library/WebServer/Documents/tools/phpdig/includes |
Those both sounded like very good, promising ideas.
Unfortunately, my perssions were already set to those values, so that wasn't the problem. Edited my php.ini just to give that a try, and it didn't change anything at all -- still get the same errors. If I didn't know any better, I'd say that it seems like from the command line spider.php is still trying to use $relative_script_path instead of falling back on the ABSOLUTE_SCRIPT_PATH. That's the only way I can figure it'd work fine from the website but not from the command line... but I could be way off on that one. |
The $relative_script_path is used throughout the script, but it should be relative to wherever you are in the script. The ABSOLUTE_SCRIPT_PATH is so you can call PhpDig from shell while being outside the admin directory, but once called, the $relative_script_path should be page relative... unless... what's your "doc_root" set to in your php.ini file?
|
I had to check and... It's not set to anything.
|
Hmm, is your /usr/local/php/bin/php running under user root?
|
I believe so... it's running as whatever the default is -- pretty sure that's root (but I have to admit I don't know how to check or change that). /usr/local/php/bin/php is owned by root....
|
What's a link to your PHP info?
|
Don't wanna be a jerk, but there's some sensitive info on that page... (namely PHP_AUTH_PW) but PHP_AUTH_USER is "xxxxxx" -- anything in particular you want to see on that page?
|
All times are GMT -8. The time now is 10:31 PM. |
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.