EasyApache 4 Cron Issue
After updating a server to EasyApache 4 I noticed that several cron jobs quit working. After some testing, I've determined that PHP scripts running as crons are not properly including files from upper level directories after EasyApache 4 is installed.
To demonstrate the issue, I created a simple PHP script with two files:
The first file is public_html/config.php with the following contents:
$dbhost = 'localhost';
$dbname = 'testsite_database';
$dbuser = 'testsite_dbuser';
$dbpass = 'Testing123';
?>
And the second file is public_html/testdir/testfile.php with the contents:
require "../config.php";
$dblink = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("Unable to connect to database");
mysqli_query($dblink, "INSERT INTO log (logentry) VALUES ('Successfully ran file at ".date("F j, Y, g:i:s a")."')");
?>
When I open testdir/testfile.php in my browser, the file runs fine with both EasyApache 3 and EasyApache 4.
I added the file as a cron job with the command:
/usr/bin/php -f /home/testsite/public_html/testdir/testfile.php
In EasyApache 3 the file continues working as expected. However, after upgrading to EasyApache 4, the file terminates with a fatal error:
[12-Mar-2016 22:23:01 UTC] PHP Warning: require(../config.php): failed to open stream: No such file or directory in /home/testsite/public_html/testdir/testfile.php on line 3
[12-Mar-2016 22:23:01 UTC] PHP Fatal error: require(): Failed opening required '../config.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/testsite/public_html/testdir/testfile.php on line 3
I've reverted back to EasyApache 3 and reinstalled EasyApache 4 several times, and the results have been consistent. The file always runs fine when I open it in a browser, and it works fine as a cron in EasyApache 3, but it fails to run as a cron in EasyApache 4. The file also works fine as a cron on a different server where CloudLinux is installed. I used PHP 5.6 in each test.
Another thing I noticed is that when running as a cron in EasyApache 4, the errors are written to the user's home directory /home/testsite/error_log rather than the directory in which the PHP file was executed. I wasn't sure if this was by design, or if it could be related to the issue.
-
Hi, We're doing some testing internally checking this out right now. I hope to have a little more information on this shortly. Thanks for your report! 0 -
Hi, We've replicated this and opened case EA-4337 to get this fixed. Thanks for your report! 0 -
Has there been any kind of resolve to this yet? I believe I have this same issue or something along this line. I have a very basic cron job and they "cron's" have completely stopped working. Manually, everything is fine. Just want to know if there is a solution or if I should fall back to easyapache 3. Thanks! Kirk 0 -
Hi, As a temporary workaround, you can call the SCL PHP version + -cgi that you want to execute. IE: Instead of /usr/bin/php, instead call the interpreter: /opt/cpanel/ea-php##/usr/bin/php-cgi We're looking at different solutions right now, and hope to have something out shortly to fix. 0 -
I think you just threw me into noob town. haha. What exactly are we doing here. Are we working inside cpanel under crons? I tried inserting this into the cron line a bunch of ways with no success but I feel like I am doing this wrong. Sorry to bother! 0 -
What exactly are we doing here. Are we working inside cpanel under crons? I tried inserting this into the cron line a bunch of ways with no success but I feel like I am doing this wrong.
Hello :) Could you let us know what you entered for the cron job? For instance, did you replace "ea-php##" with the actual PHP version number? Thank you.0 -
Hey! I added the line as /opt/cpanel/ea-php70/usr/bin/php-cgi Would this be correct? I got this error. /bin/sh: /opt/cpanel/ea-php70/usr/bin/php-cgi: No such file or directory Thanks! 0 -
Hi, Sorry! I didn't put the full path properly, my bad. The full path to that versions php-cgi would be: /opt/cpanel/ea-php70/root/usr/bin/php-cgi The cron would look something like (as an example): * * * * * /opt/cpanel/ea-php70/root/usr/bin/php-cgi /home/perk/public_html/cron.php I hope this helps! 0 -
Thanks! It worked. Sorry for being a little lost there. It was strange, at first, the cron didn't work. then after the second minute it kicked in and started working. Non the less. Its working. I can get on with things for now. Thanks a ton! 0 -
I'm still experiencing this bug in EA4 after updating to 58.0.3. Changing "/usr/bin/php" to "/opt/cpanel/ea-php56/root/usr/bin/php-cgi" in the cron command seems to fix the issue, but that still means that the client's existing cron jobs will stop working after migrating from EA3 to EA4. I don't think EA4 should be released out of BETA until this bug is fixed, since it would affect a large number of clients and also coding the PHP version into the commands will cause further confusion and issues if the clients wish to change to a different version of PHP. Since CloudLinux offers multiple PHP versions and the "/usr/bin/php" cron commands work fine on CloudLinux servers, couldn't a similar method of running crons be implemented in EA4? 0 -
I'm still experiencing this bug in EA4 after updating to 58.0.3.
Hello, A resolution for case EA-4337 has not been published. I'll update this thread as soon as more information on the time frame of the resolution is available. Thank you.0 -
Hi, We are planning to get a temporary fix out to get this taken care of while we plan the proper fixes in the background. We have an emergency release tomorrow with PHP updates, however I plan to get a quick fix in ASAP and get it public. I'll update this thread once we get it into our development branches. Thanks for our patience! 0 -
Hi, I have a fix in testing, and I was wondering if anyone would be interested in testing this out on their system. It's just a simple RPM upgrade, and should be quick for testing. Anyone interested? 0 -
I'd be happy to test out the fix on my test server. How do I install it? 0 -
Hi Josh, Here's a link to an RPM that you can download and install, and then test out. I put this on my personal website for easy access. Simply install the RPM, and you should be able to start testing your crons immediately. Let me know how it goes! Thank you! rpm -Uvh http://houstondad.com/ea-php-cli-0.0.6-4.5.1.cpanel.x86_64.rpm
0 -
I installed the RPM, and it looks like the fix is working perfectly. All the "/usr/bin/php" cron commands seem to be working in EA4 and I'm not seeing any errors. Thanks for the fix! 0 -
Hi Josh, Thanks for the update! We'll get this merged into master and sent out in our next release. 0 -
Hi Josh, Thanks for the update! We'll get this merged into master and sent out in our next release.
Just to ask will this work also with using like thsi: php /some/file.php0 -
Hi, I believe this should, yes. The PHP wrapper itself is pointing to php-cgi, so this should work no matter where it was called. 0 -
This thread isn't the easiest to clearly understand. Is the jist of this issue that after converting to EasyApache 4, the php-cli binary is missing? I have a cron event that runs php-cli. a 'find / -name php-cli' indicates it is now nowhere to be found on the system. However looking at my EasyApache 4 profile, it shows that php-cli modules are enabled. So I downloaded the rpm per instructions below but php-cli is still missing. I am guessing there is an additional step to installing php-cli that cPJacob did not include? Hi Josh, Here's a link to an RPM that you can download and install, and then test out. I put this on my personal website for easy access. Simply install the RPM, and you should be able to start testing your crons immediately. yum install php-cli results in 'no package php-cli available' Let me know how it goes! Thank you!
rpm -Uvh http://houstondad.com/ea-php-cli-0.0.6-4.5.1.cpanel.x86_64.rpm
0 -
I have a cron event that runs php-cli. a 'find / -name php-cli' indicates it is now nowhere to be found on the system. However looking at my EasyApache 4 profile, it shows that php-cli modules are enabled.
What's the specific command you use in the cron job? Is it no longer working with EasyApache 4? Thank you.0 -
Hi Josh, Here's a link to an RPM that you can download and install, and then test out. I put this on my personal website for easy access. Simply install the RPM, and you should be able to start testing your crons immediately. Let me know how it goes! Thank you!
rpm -Uvh http://houstondad.com/ea-php-cli-0.0.6-4.5.1.cpanel.x86_64.rpm
There's an issue with this package that breaks CLI arguments and requires absolute paths for files. This breaks cron tasks in all kinds of fun ways AND isn't fixed by reverting to 6-4.4.2.cpanel. Good times. EDIT: looks like the issue is related to php-cgi[root@tempwhm ~]# /opt/cpanel/ea-php56/root/usr/bin/php-cgi ./args.php 1 2 3 4 Content-type: text/html; charset=UTF-8 NULL NULL [root@tempwhm ~]# /opt/cpanel/ea-php56/root/usr/bin/php ./args.php 1 2 3 4 int(5) array(5) { [0]=> string(10) "./args.php" [1]=> string(1) "1" [2]=> string(1) "2" [3]=> string(1) "3" [4]=> string(1) "4" } [root@tempwhm ~]#
Example of php-cli behavior:args.php = [root@tempwhm ~]# php args.php 1 2 3 4 5 Status: 404 Not Found Content-type: text/html; charset=UTF-8 No input file specified. [root@tempwhm ~]# [root@tempwhm ~]# php ./args.php 1 2 3 4 5 Content-type: text/html; charset=UTF-8 NULL NULL [root@tempwhm ~]# /opt/cpanel/ea-php56/root/usr/bin/php args.php 1 2 3 4 5 int(6) array(6) { [0]=> string(8) "args.php" [1]=> string(1) "1" [2]=> string(1) "2" [3]=> string(1) "3" [4]=> string(1) "4" [5]=> string(1) "5" } [root@tempwhm ~]#
0 -
Hi, What is your include_path with this? That would cause these absolute paths to not be found properly. That's what we're seeing internally when we're testing this patch. Could you verify for me please? 0 -
Hi, What is your include_path with this? That would cause these absolute paths to not be found properly. That's what we're seeing internally when we're testing this patch. Could you verify for me please?
Was busy hammering things out in github and we got things straightened out. Basically "/usr/local/bin/php will link to php-cli while /usr/bin/php will link to php-cgi" Updating to php-cgi instead of using cli causing whole lot of issues " Issue #1 " CpanelInc/php-cli " GitHub "It's not too hard to have our RPM spit out another binary in a new place. We've opened case EA-5106 to get this done, and I hope that we can have it complete, tested and pushed out next Tuesday."0 -
Haha, that was me :D 0 -
Derp! 0 -
Hi, What exact issues are you having with crons? Could you elaborate? 0 -
Sure, they stopped running after upgrading to easyapache 4 with under php5.6 I've tried several different methods to call the function and they are all failing. Before the upgrade to 4 the first job ran fine. /usr/local/bin/php -f /home/machineparts/public_html/cron.php >> /home/machineparts/public_html/var/log/cron.log 2>&1 Edit /opt/cpanel/ea-php56/root/usr/bin/php -f /home/machineparts/public_html/cron.php >> /home/machineparts/public_html/var/log/cron.log 2>&1 Here's a list of the packages currently installed [LIST] - ea-apache24
- ea-apache24-config
- ea-apache24-config-runtime
- ea-apache24-mod_bwlimited
- ea-apache24-mod_cgi
- ea-apache24-mod_deflate
- ea-apache24-mod_expires
- ea-apache24-mod_headers
- ea-apache24-mod_mpm_prefork
- ea-apache24-mod_proxy
- ea-apache24-mod_proxy_fcgi
- ea-apache24-mod_proxy_http
- ea-apache24-mod_ruid2
- ea-apache24-mod_security2
- ea-apache24-mod_ssl
- ea-apache24-mod_unique_id
- ea-apache24-tools
- ea-apr
- ea-apr-util
- ea-cpanel-tools
- ea-documentroot
- ea-libmcrypt
- ea-php-cli
- ea-php55
- ea-php55-libc-client
- ea-php55-pear
- ea-php55-php-bcmath
- ea-php55-php-calendar
- ea-php55-php-cli
- ea-php55-php-common
- ea-php55-php-curl
- ea-php55-php-devel
- ea-php55-php-fpm
- ea-php55-php-ftp
- ea-php55-php-gd
- ea-php55-php-iconv
- ea-php55-php-imap
- ea-php55-php-mcrypt
- ea-php55-php-mysqlnd
- ea-php55-php-pdo
- ea-php55-php-posix
- ea-php55-php-soap
- ea-php55-php-sockets
- ea-php55-php-xml
- ea-php55-php-zendguard
- ea-php55-runtime
- ea-php56
- ea-php56-libc-client
- ea-php56-pear
- ea-php56-php-bcmath
- ea-php56-php-calendar
- ea-php56-php-cli
- ea-php56-php-common
- ea-php56-php-curl
- ea-php56-php-devel
- ea-php56-php-fpm
- ea-php56-php-ftp
- ea-php56-php-gd
- ea-php56-php-iconv
- ea-php56-php-imap
- ea-php56-php-ioncube
- ea-php56-php-mbstring
- ea-php56-php-mcrypt
- ea-php56-php-mysqlnd
- ea-php56-php-pdo
- ea-php56-php-posix
- ea-php56-php-soap
- ea-php56-php-sockets
- ea-php56-php-xml
- ea-php56-php-zendguard
- ea-php56-runtime
- ea-php70
- ea-php70-libc-client
- ea-php70-pear
- ea-php70-php
- ea-php70-php-bcmath
- ea-php70-php-calendar
- ea-php70-php-cli
- ea-php70-php-common
- ea-php70-php-curl
- ea-php70-php-devel
- ea-php70-php-fpm
- ea-php70-php-ftp
- ea-php70-php-gd
- ea-php70-php-iconv
- ea-php70-php-imap
- ea-php70-php-mcrypt
- ea-php70-php-mysqlnd
- ea-php70-php-opcache
- ea-php70-php-pdo
- ea-php70-php-posix
- ea-php70-php-soap
- ea-php70-php-sockets
- ea-php70-php-xml
- ea-php70-runtime
- ea-profiles-cpanel Thanks for the assist!
0 -
Hi, Would you mind throwing in a ticket so we can take a look at this? Thanks! 0
Please sign in to leave a comment.
Comments
32 comments