I'm having an issue with PHP require (I think) and crontab. I'm using AWS.
The error looks like this:
PHP Fatal error: require(): Failed opening required '/inc/classes/core/inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/inc/files/core/config.php on line 16
My PHP require looks like this:
require($_SERVER['DOCUMENT_ROOT'].'/inc/files/core/config.php');
There are similar issues here about the same thing and I looked at them, but their solutions didn't seem to work for me. One of the things I tried from Stackoverflow was this:
$_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__).'/../../../../');
require($_SERVER['DOCUMENT_ROOT'].'/inc/files/core/config.php');
Another was adding this to my php ini file (also a suggestion from another thread):
include_path = ".:/usr/share/php:/var/www/<directory>/"
I also tried being direct with the path (i.e., /var/www/public/inc/etc) which didn't work.
My file dictionary is like:
- public
- -- inc
- ---- files
- ------ site
- -------- cron
- -- etc
- -- etc
I should note that the requires are the same on every page and they work, except in the cron job. I read that this could be because of the $_SERVER['DOCUMENT_ROOT'] var being set by the user as they browse and can't be set by the crontab, but I can't figure out the fix.
The crontab looks like this, but it seems to send an email every 5 minutes like it's supposed to so I don't think there's any issue here.
*/5 * * * * /usr/bin/php /var/www/html/inc/files/site/cron/shop.php
I'm hoping someone has some insight on this because I'm stumped! I didn't set up any of the crontab work but the person who did left, and I'm not familiar with it.
I put in all the information here I could think of, but I'm happy to answer any additional questions.