PHP Cron问题 - 使用plesk:动态库,open_basedir

时间:2012-02-27 05:53:33

标签: php cron crontab plesk

我通过plesk(控制面板)crontab输入以下命令,每小时运行一次php文件:

php httpdocs/cron/script.php

我收到以下2条错误消息(每小时一次,发送到我的电子邮箱):

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/http.so' -
/usr/lib/php/modules/http.so: cannot open shared object file: No such file or directory in
Unknown on line 0
PHP Warning:  require_once(): open_basedir restriction in effect.
File(../include/functions.php) is not within the allowed path(s):
(/var/www/vhosts/basedomain.com:/tmp) in /var/www/vhosts/example.com/httpdocs/cron/script.php
on line 2
PHP Warning:  require_once(../include/functions.php): failed to open stream: Operation not
permitted in /var/www/vhosts/example.com/httpdocs/cron/script.php on line 2
PHP Fatal error:  require_once(): Failed opening required '../include/functions.php'
(include_path='.:') in /var/www/vhosts/example.com/httpdocs/cron/script.php on line 2

注意:第2行有require_once(../include/functions.php);

我意识到这些是两个不同的问题。我尝试分别解决每个问题,他们仍然和我在一起。任何帮助,将不胜感激。感谢

2 个答案:

答案 0 :(得分:1)

请检查下面,也许它会对你有帮助。 http://www.geeklog.net/forum/viewtopic.php?showtopic=28107

答案 1 :(得分:1)

当您像这样运行PHP时,在Plesk特定位置和特定于Apache的位置(如vhost.conf)中的配置集不适用。

由于您的脚本已在httpdocs中,为什么不使用wget / curl通过HTTP调用脚本?像/usr/bin/curl http://yoursite.com/cron/script.php 2>&1这样的东西。可能需要考虑一些额外的验证(IP限制,htpasswd auth)以确保随机访问者(脚本小子)无法运行它。