PHP Cron问题 - 使用plesk:动态库,open_basedir [英] PHP Cron Problems - using plesk: dynamic library, open_basedir

查看:377
本文介绍了PHP Cron问题 - 使用plesk:动态库,open_basedir的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I entered the following command through plesk (control panel) crontab, to run a php file once an hour:

php httpdocs/cron/script.php

我得到以下2个错误消息我的电子邮件):

And I am getting the following 2 error messages (once an hour, to my email):

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);

我意识到这是两个不同的问题。我试着单独解决它们,他们都还在我身边。任何帮助,将不胜感激。感谢

I realized these are 2 different issues. I tried solving each separately and they are both still with me. Any help would be appreciated. Thanks

推荐答案

当你像这样运行PHP时,配置集合在Plesk特定和Apache-特定的地方如vhost.conf'

When you run PHP like this, configuration set in Plesk-specific and Apache-specific places like vhost.conf doesn't apply.

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

Since your script is already inside httpdocs, why don't you just use wget/curl to invoke the script through HTTP? Something like /usr/bin/curl http://yoursite.com/cron/script.php 2>&1. Might want to consider some additional validation (IP limiting, htpasswd auth) to make sure random visitors (script kiddies) can't run it.

这篇关于PHP Cron问题 - 使用plesk:动态库,open_basedir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆