PHP version keeps changing automatically
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:
[CODE=apacheconf]
# php -- BEGIN cPanel-generated handler, do not edit
# Set the "ea-php73" package as the default "PHP" programming language.
AddHandler application/x-httpd-ea-php73___lsphp .php .php7 .phtml
# php -- END cPanel-generated handler, do not edit
to [CODE=apacheconf]# php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php54" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php54___lsphp .php .php5 .phtml # 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. 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.
to [CODE=apacheconf]# php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php54" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php54___lsphp .php .php5 .phtml # 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. 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.
-
@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? 0 -
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. 0 -
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. 0 -
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. 0 -
Hi @dk123 Can you try this using the MultiPHP Manager rather than do it manually and let me know if you continue to see the reversion? 0 -
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. 0 -
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?) 0 -
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. 0 -
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. 0 -
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. 0 -
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 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.0 -
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. 0 -
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: 0 -
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? 0 -
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?0 -
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: # php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php56" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php56 .php .php5 .phtml # 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?0 -
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: # php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php72" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php72 .php .php7 .phtml # 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!0 -
That definitely sounds odd - if you have root access to the machine could you open a ticket with our team so we could examine this directly on the system? 0 -
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. 0 -
@FenTaylor - could you open a ticket with our Technical Support team so we can investigate that? 0 -
We are seeing this happen to one website. It randomly changes from the set version of 7.4 to 5.6. When you look in WHM or cPanel, it shows 7.4. The thing I find interesting is if you go into MultiPHP INI Editor, it asks you to select a location.. the Home directory or the web root. If you select the web root, it shows the current version as 7.4. If you select the Home directory, it shows 5.6. Neither folder has a PHP.ini file. Not sure what that is all about but may be a lead as to what is causing this? 0 -
@DeShark - do you have a .htaccess file in either of those directories? If so, I would expect that to have the standard PHP configuration line near the bottom: # php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php56" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php56 .php .php5 .phtml # php -- END cPanel-generated handler, do not edit
0 -
Yes,.. in the web root directory, When it switches to 5.6 the .htaccess file disappears. Here is the current one.. # php -- BEGIN cPanel-generated handler, do not edit # Set the "ea-php74" package as the default "PHP" programming language. AddHandler application/x-httpd-ea-php74 .php .php7 .phtml # php -- END cPanel-generated handler, do not edit 0 -
Alright, that's a good first step. Now, when it seemingly randomly changes the PHP version, does the .htaccess data also change? 0 -
There is no .htaccess file when its running 5.6. It appears to get deleted. If I delete it, it runs 5.6. 0 -
Thanks for that - it sounds like this would be best handled through a ticket so we can check the domain and server settings, as there really should not be much else controlling the version for an account. If you are able to open a ticket, please post the number here so I can follow along and keep this thread updated. 0 -
What settings are there to check for this type of situation? I am happy to look into it. 0 -
It really depends - do you know what action causes it to change? Is this frequently detected in the morning, which could indicate an overnight update reset something? Or it is really completely random? 0 -
Seems to be random. 0 -
You've mentioned that WHM shows 7.4 no matter when you check - when the version is changed to 5.6, does the .htaccess also still show 7.4? *Something* must be indicating the change, or do you only see this in a PHP info page? I guess I need to know where you're seeing the change take place so I can know where to start looking. 0
Please sign in to leave a comment.
Comments
38 comments