Soren Beck Jensen

Registered
Jul 11, 2019
2
0
1
Granada, Spain
cPanel Access Level
Root Administrator
We have been having this issue for ages, and have even moved servers because we thought our last provider was doing something wrong. But the issue has followed us. We have observed this issue on at least 2 different sites, but it mostly happens to one specific site (our most important one of course). It happens at all times of day and with 2-3 weeks in between, sometimes only days. Last night it happened at 03:34 where I am 100% sure no one was working on it. But as said, it has also happened during the day

The bottom bit of our .htaccess file is changed from:

Apache config:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
to

Apache config:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php54” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php54___lsphp .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
But the really weird bit is that it still shows as php 7.3 in both cPanel and WHM screens. Just now when checking I have realized that the two domain that it has happened on both have subdomain that use the older version of PHP so it is likely this is related.

1585815593382.png
To fix the issue, we set the site back to and older version and then back to 7.3 again. To re-iterate... the above does not change, only the .htaccess changes (when the problem happens).

Any help will be appreciated.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
@Soren Beck Jensen I don't know of anything that would change the AddHandler in that specific IfModule, some software might add an AddHandler but not modify the existing one from what I've seen.

I noticed that the payment subdomain is noted as being affected by changes to the root domain. Is there not an .htaccess in the payment.subdomain's document root? Within that .htaccess is the AddHandler set? Furthermore is the PHP version for those two sites (the root domain and subdomain) the same across all avenues? Which OS are you running? CentOS or CloudLinux?
 
Last edited:

Soren Beck Jensen

Registered
Jul 11, 2019
2
0
1
Granada, Spain
cPanel Access Level
Root Administrator
I have now changed the subdomain to also run 7.3 so I am not sure if there was one. I would imagine that there was as the default version is 7.3 so any domain not running 7.3 must have been set and using an .htaccess. I am quite convinced that the issue stemmed from subdomains running an older version, but I am not sure. If we experience the issue again (now after having changed the subdomain) I will update this thread. For other users experiencing this, I recommend setting all sub domains to the same PHP version.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Well, actually what I was suggesting was that there wasn't an .htaccess in the payment subdomain's document root and I'd wanted to see if adding one actually resolved the issue for you. There should be no issue having different PHP versions in different subdomains, I have a similar configuration on my testing server with no issues.
 

dk123

Registered
Jun 3, 2020
1
1
0
Melbourne
cPanel Access Level
Website Owner
i have the exact same problem. googling for answers and ended up here. I keep changing the htaccess file to an updated php version, exactly the same as in the original post. then randomly when i return to wordpress i get messages that my php needs updating, and when i check the htaccess file again, it has reverted to the addhandler with php5 info.
 
  • Like
Reactions: james102338

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
631
207
343
cPanel Access Level
DataCenter Provider
It's a longshot, but are you running WordPress on either of these domains? We had a client running a WordPress plugin (sorry I can't remember the name) and the plugin backed up all the files in the site and automatically put them back if they were changed outside of WordPress. This drove us crazy for a while until we figured out what it was.
 

AikiDigital

Registered
Jul 9, 2020
1
0
1
US
cPanel Access Level
Root Administrator
Thanks for that tip, ffeingol
I am having a similar issue and I was suspecting that a plugin was writing to .htaccess and causing this to happen for us as well. Any chance you might remember which plugin it was or even what type of plugin it was (backup, caching, optimization?)
 

imorandin

Member
PartnerNOC
Nov 20, 2014
17
1
53
cPanel Access Level
DataCenter Provider
Hi. I have the same problem in 2 accounts in different servers. One site is Wordpress but the other is not (custom PHP site).
I think that this has to do with cpanel update because the htaccess modification time is the same as the upcp log.
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
631
207
343
cPanel Access Level
DataCenter Provider
The only other instance we've see of this is when the customer went in (or their software) rewrote the .htaccess file and removed the cPanel code to set the PHP version. There seems to be something that runs nightly and makes sure the the PHP version (or lack of) in the .htaccess matches what they have configured via cPanel. This is just observation, someone from cPanel will have to confirm this behavior.
 

kesz1

Registered
Oct 15, 2020
1
1
0
NJ
cPanel Access Level
Website Owner
Anyone find a solution? I have 12 subdomains on one site (custom php) and have the same issue as the OP. The .htaccess file reverts php back to 5.6 from 7.3. When I login to PHP manager the sites still show 7.3 and I have to reset them to 7.3 (weird I know) in order to rewrite the .htaccess file.
 
  • Like
Reactions: SDSurfer

SDSurfer

Member
Apr 10, 2014
8
0
51
cPanel Access Level
Root Administrator
This is a bit of a crazy way to set version for an entire domain, but am glad I found this thread because it's still done this way and can confirm that is EXACTLY what Worpdress is doing, overwriting the .htaccess. When you go to the site health link it asks you to flush rules but it appears to do so even if you don't hit the link. FTR I was using the Multi PHP Manager.

1) Can't we do this manually in the Apache configuration? that would be the best fix, I think. Or ....
2) In updating to PHP 7.4, I noticed it uninstalled all the 5+ versions without issue. If you don't need prior versions, this would stop it from happening (I think?)
3) The other thing is to FIX WORDPRESS. :) (or tell it not to do this.) It's set up this way to allow non-technical people deal with it, but if you can code to any degree you don't need this functionality. One of my sites doesn't revert. In my theme setup (generally functions.php) I have

Code:
add_filter('flush_rewrite_rules_hard','__return_false');
This stops WP from overwriting the .htaccess - but keep in mind you now have to manually maintain its contents.

EDIT: I am guessing it's because the handler chunk comments have BEGIN and END in caps and (possibly) this is what Wordpress is looking for when it rewrites .htaccess, it uses BEGIN and END too.
 
Last edited:

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
631
207
343
cPanel Access Level
DataCenter Provider
I don't believe that this is actually WordPress doing this. WordPress adds some "comments" that surround the WordPress rewrites and that seems to be the only thing it touches. It may, however, be a Wordpress plugin (like a cache plugin etc.) that adds code to the .htaccess.

Just my 2 cents.
 

MarkPW

Member
Jun 8, 2003
16
0
151
I'm having the same issue on my dedicated server and do not use Wordpress. cPanel will every now and then change the PHP version of the parent domain on one of my accounts regardless of the PHP version assigned in MultiPHP Manager. It's set to 7.1.33, last week it assigned 5.6, and now it's 7.2.34. Any ideas what's going on? :oops:
 

MarkPW

Member
Jun 8, 2003
16
0
151
If there any manual edits to the .htaccess file on the system that could cause this behavior to happen. When the change happens, do you see that reflected inside the local .htaccess file?
I do see the change reflected in .htaccess.

I notice each time this happens cPanel has rebuilt all installed PHP versions, this is happening without any manual intervention from me. Is that normal?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,494
1,009
313
cPanel Access Level
Root Administrator
That's correct - if you're manually changing the PHP version data in the .htaccess file, cPanel will overwrite that with what is setup in the WHM or cPanel interfaces, as those settings get stored in various configuration files across the system. The PHP block also has a notice about not making edits, as shown here:

Code:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Can you make sure the PHP version is set in WHM or cPanel for the domain through the interface so that file doesn't get overwritten?
 

MarkPW

Member
Jun 8, 2003
16
0
151
MultiPHP for my root domain is set to 7.1.33 and that setting hasn't changed. My htaccess file has been updated automatically to:

Code:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
I've never manually edited that rule.

Root domain is running on 7.2.34. MultiPHP is still set to 7.1.33.

subdomains are using the version assigned in MultiPHP as expected.

All this is happening without me changing anything; htaccess, server settings, or otherwise. cPanel is rebuilding and assigning the wrong PHP version all by itself!
 

FenTaylor

Registered
Jul 15, 2021
1
0
1
Texas
cPanel Access Level
Root Administrator
We faced the same problem. It has never been there before, but it has appeared twice in the last two weeks. At night, the php version changes by itself and all sites stop working (because they require php 7.3). The problem is solved very simply: MultiPHP Manager -> select php 7.3 -> Apply. But all this time, until you change it, the sites will not work, and this is the problem.

Does anyone have any ideas how to fix it? Thank you.
 

Attachments