I entered the following command through plesk (control panel) crontab, to run a php file once an hour:
php httpdocs/cron/script.php
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
Note: Line 2 has 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
When you run PHP like this, configuration set in Plesk-specific and Apache-specific places like vhost.conf doesn't apply.
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.
Please check below, maybe it will help you.
http://www.geeklog.net/forum/viewtopic.php?showtopic=28107
Related
I have recently been trying to add PHPMailer script to my site, following the accepted answer from here:
Send attachments with PHP Mail()?
I have never used a require statment before so I assume I must be doing it wrong, currently testing on my local host version of the site. I have downloaded the entire zip of git (unzipped it) and moved it to the dir my scripts are in.
In my script I added the following line:
require_once(__DIR__.'/PHPMailer-master/class.phpmailer.php');
Which to my understanding was all I needed to do to use it. However I get this error:
Warning:
require_once(C:\xampp\htdocs\Website\PHPMailer-master\class.phpmailer.php):
failed to open stream: No such file or directory in
C:\xampp\htdocs\Website\include\mailer.php on line 10
Fatal error: require_once(): Failed opening required
'C:\xampp\htdocs\Website\PHPMailer-master\class.phpmailer.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\Website\include\mailer.php on line 10
Any ideas what is causing this error? Am running PHP 5.6.21 if this is relevant.
Try to use the full path to the file, using realpath() - http://php.net/realpath, and use dirname(__FILE__) to get your current directory:
So I have a script that updates all currency rates for my webshop.
I am trying to have it run using a cronjob but when it's executed through a cronjob I get this error:
PHP Warning: require(.../.../core/dbcon.php): failed to open stream: No such file or directory in /var/www/domain.com/wholesale/system/labs/cur.php on line 2
PHP Fatal error: require(): Failed opening required '.../.../core/dbcon.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/domain.com/wholesale/system/labs/cur.php on line 2
I've also tried using the full link to include it but that seems to not work when running it manually and will also not work in cronjobs.
In the php file itself this is what I use to include it:
require(".../.../core/dbcon.php");
And when I manually run it, it returns all the currencies right, and updates them in the database.
How would I correctly require the file so it can execute using a cronjob and manually as well.
Try require("./../../core/dbcon.php");
or use absolute paths.
UPDATE
Answer has been updated - see comments below for more info.
Okay.
So on line 37 on this script http://ideone.com/grapQ the include_once command is basically just being ignored and the content I am trying to show is not showing up at all, not even a error message.
I tried enabled error reporting and not one a single error is being shown.
Also i tried using Echo and the same issue persist.
Does anyone have any ideas on why its being ignored and not even a error message is being shown? More than luck just its just something basic!
You are missing a semi-colon on the end of that include statement:
include_once('http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php');
Additionally, when I tested it (just that line) here on my local machine, I got the following errors:
Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/test.php on line 5
Warning: include_once(http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php): failed to open stream: no suitable wrapper could be found in /var/www/test.php on line 5
Warning: include_once(): Failed opening 'http://outside-resources.ultimatesphider.com/us-resources/2.0.1/2.0.1announce.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/test.php on line 5
Deepak's answer has more information on allowing external files that probably applies to your question.
You cannot include remote files as it is in PHP 5.2.0 and later versions. If you want to use remote URL allow_url_include must be enabled for these. Refer Link
follow the link
http://php.net/manual/en/function.include-once.php
I have mysql_connect running with no problem on my site...
I have a script that i'm running from a CRON job, and here it decides to not work, and output these two errors:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0
Fatal error: Call to undefined function mysql_connect() in /home/mysite/public_html/phpMySQLAutoBackup/files/schema_for_export.php on line 22
Yes, I'm using phpMySQLAutoBackup
Any ideas? This befuddles me...
The time I got one of these (Unable to load dynamic library ...) I was missing a module. In your case my guess would be that you're missing "libssh2"
Similar to PHP Errors on a cronjob, works fine at prompt
Check your $PATH, permissions, & any environment variables...
Here is the first error:
Warning: require(/hb/includes/constants.php) [function.require]: failed to open stream: No such file or directory in C:\wamp2\www\hb\includes\connection.php on line 2
And the second error that immediately follows:
Fatal error: require() [function.require]: Failed opening required '/hb/includes/constants.php' (include_path='.;C:\php\pear') in C:\wamp2\www\hb\includes\connection.php on line 2
Here is the line that it doesn't like:
require("/hb/includes/constants.php");
I did install a new version of WAMP, but I know the directories/files are fine and the code worked previously and on another server. It seems like none of my require()'s are working anymore. I tried looking around and some suggested to others that they edit their php.ini, but I don't know what directory I would point to - if you can't tell I'm pretty noobish regarding all things server related.
Any help is appreciated.
First of all, are your really -- really ! -- sure that the file /hb/includes/constants.php, that your are trying to include, exists ?
Considering that the path you requested begins with a /, it looks like you're using an absolute path... that looks like an UNIX path, but you are on a Windows server...
If it exists, and PHP still cannot include it, check :
that it is readable by your webserver (including the directories) -- I'm thinking about UNIX permissions
that there is no open_basedir restriction that would prevent PHP from accessing those files.
BTW, having a warning and a fatal error is the behavior that's to be expected when using require : the warning is normal (it comes from include) ; and the fatal error is the difference between include and require.