Josh Abbott

Member
Oct 4, 2015
9
0
51
US
cPanel Access Level
Root Administrator
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:

<?php
$dbhost = 'localhost';
$dbname = 'testsite_database';
$dbuser = 'testsite_dbuser';
$dbpass = 'Testing123';

?>

And the second file is public_html/testdir/testfile.php with the contents:

<?php
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.
 

kirklove

Registered
Mar 23, 2016
4
0
51
Buffalo, NY
cPanel Access Level
Root Administrator
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
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
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.
 

kirklove

Registered
Mar 23, 2016
4
0
51
Buffalo, NY
cPanel Access Level
Root Administrator
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!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
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.
 

kirklove

Registered
Mar 23, 2016
4
0
51
Buffalo, NY
cPanel Access Level
Root Administrator
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!
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
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!
 
  • Like
Reactions: kirklove

kirklove

Registered
Mar 23, 2016
4
0
51
Buffalo, NY
cPanel Access Level
Root Administrator
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!
 

Josh Abbott

Member
Oct 4, 2015
9
0
51
US
cPanel Access Level
Root Administrator
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
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.
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
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!
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
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?
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
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!

Code:
rpm -Uvh http://houstondad.com/ea-php-cli-0.0.6-4.5.1.cpanel.x86_64.rpm
 

Josh Abbott

Member
Oct 4, 2015
9
0
51
US
cPanel Access Level
Root Administrator
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!