pronamic / siteground

Repository to keep track of the collaboration between Pronamic and SiteGround.
1 stars 0 forks source link

Update PHP version via CLI `site-tools-client`? #2

Closed remcotolsma closed 8 months ago

remcotolsma commented 9 months ago

As far as we have seen, it is not (yet) possible to update the PHP version via the site-tools-client CLI command:

site-tools-client -j domain update id=1 php_version=74
{
   "err_code" : 400,
   "err_fields" : {
      "err_meta" : {
         "php_version" : "74"
      },
      "php_version" : 1
   },
   "message" : "Unsupported parameter"
}

We need to investigate this further or ask SiteGround support.

In the "WordPress Netherlands" Slack workspace there were also some users who were surprised that PHP version 7.4 is still the standard.

https://wpnl.slack.com/archives/C02S9PN00/p1705056024167739?thread_ts=1705056024.167739

@rvdsteege didn't SiteGround indicate that they were working on this?

For WP-CLI, using php81 /usr/local/bin/wp-cli.phar is also not very convenient.

Currently, WP-CLI at SiteGround still runs via PHP 7.4, regardless of which PHP version you set via the SiteTools. Through SiteGround support we learned that WP-CLI can also be run via other PHP versions:

php56 /usr/local/bin/wp-cli.phar
php70 /usr/local/bin/wp-cli.phar
php71 /usr/local/bin/wp-cli.phar
php72 /usr/local/bin/wp-cli.phar
php73 /usr/local/bin/wp-cli.phar
php74 /usr/local/bin/wp-cli.phar
php80 /usr/local/bin/wp-cli.phar
php81 /usr/local/bin/wp-cli.phar
php82 /usr/local/bin/wp-cli.phar
php83 /usr/local/bin/wp-cli.phar

Via the --info parameter you can view the PHP version that WP-CLI uses:

/usr/local/bin/wp-cli.phar --info
OS:   Linux ams44.siteground.eu 5.15.126-MCIclouder399 #399 SMP PREEMPT Wed Aug 16 16:53:17 EEST 2023 x86_64
Shell:    /bin/bash
PHP binary:   /usr/local/php56/bin/php-cli
PHP version:  5.6.40
php.ini used: /usr/local/php56/lib/php.ini
rvdsteege commented 9 months ago

@rvdsteege didn't SiteGround indicate that they were working on this?

Summary of chat https://my.siteground.com/support/history/chat/S3czeWEzSU0=/9537571 (Nov 15, 2023):

Pronamic: What are the plans for increasing the recommended managed PHP version? Dimitar P.: The PHP 7.4 that we use from our end is custom, it isn't the basic one that is EOL. We have patched it with security and speed improvements and it is as secure as it gets at the moment. That being said, we are constantly monitoring, investigating and troubleshooting and we wil deploy a new Managed PHP version when our developers feel is the right time to do it. Pronamic: Hmm Dimitar P.: We are aware of the need for a new managed PHP version and I can assure you that we are working on it from our end. It will certainly be in the near future, but I can't provide an exact date yet. Pronamic: Ok, that feels a bit more assuring. Any timeframe, so we can include that in our considerations to update manually or staying on the managed version for now? Dimitar P.: At the moment I can't provide the exact date, but with information like the one you are providing, it will certainly be sooner. Pronamic: Also of interest maybe for you: on https://make.wordpress.org/hosting/handbook/server-environment/#php the WordPress documentation already recommends PHP 8.1 or PHP 8.2 for hosting companies:

"WordPress supports many versions of PHP, some even obsolete (PHP Compatibility and WordPress Versions), for hosting companies we recommend: WordPress 6.4 PHP 8.1 PHP 8.2"

Dimitar P.: Thank you for this feedback. Our developers are aware of this recommendations and developments and will adjust the managed PHP version accordingly. Your feedback is deeply appreciated and I have already provided it to our managers.

Based on this conversation and the fact that we're already 2 months later, I don't expect the 'Managed PHP' version to be updated anytime soon.

remcotolsma commented 8 months ago

Ik heb SiteGround gevraagd:

Remco Tolsma: Is it also possible to log in via SSH and set the PHP version via a CLI command? Instead of having to do this via the SiteTools?

Remco Tolsma: This question is related to website: pronamic.nl

Gabriel P.: Hello, Remco!

Gabriel P.: Welcome to our live chat!

Gabriel P.: Thanks for reaching out!

Gabriel P.: You can edit the site's PHP version only via Site Tools, through the PHP Version Manager or by editing your site's .htaccess file.

Gabriel P.: May I ask why do you need to do it over SSH?

Remco Tolsma: We have dozens to hundreds of websites running for you, updating the PHP version via SiteTools is not ideal.

Remco Tolsma: We can more easily update this in bulk via SSH.

Remco Tolsma: (for you = at SiteGround) ??????

Remco Tolsma: (for you = at SiteGround) ??????

Gabriel P.: I see. Still, you would need to connect to each site individually to manage it via SSH anyway. Is there any specific set up that allows you to do it faster over SSH as opposed to using the Site Tools method?

Remco Tolsma: We already have tools/scripts in place to access al our SiteGround sites via SSH and execute commands for/on all our sites.

Gabriel P.: Thanks for confirming! The .htaccess files of your sites have priority over what's set in your PHP manager tool. If you have a way of editing the .htaccess files in bulk you can consider managing the PHP version that way, for example here's a rule that sets the site's PHP version to 8.2 AddHandler application/x-httpd-php82 .php .php5 .php4 .php3 You edit the part x-httpd-php82 if you wish to change the version, for example for PHP 7.4 it looks like this > AddHandler application/x-httpd-php74 .php .php5 .php4 .php3 And so on. You can also do this via our Multisite SFTP option > url:https://eu.siteground.com/kb/multisite-sftp-access/ which allows you to access all of the sites under a single hosting plan all at once

Remco Tolsma: Thanks, good to know.

Remco Tolsma: Other question: A few months ago we also had chat contact about updating/increasing the managed PHP version from 7.4 to, for example, 8.1. Then you indicated that a 'new managed PHP version' was being worked on, what is the status of this?

Gabriel P.: Indeed, we will be updating the managed PHP Version in the near future, although I am not aware of any concrete deadlines about it yet. We're looking to do this once we are confident that the new Managed PHP version is widely supported by most/all applications out there

Gabriel P.: If there is anything else that I can assist with, I would be happy to!

Gabriel P.: If thats all for now, I wish you a wonderful day and take care!

System: Gabriel P. has ended the chat

Blijkbaar kunnen we het via .htaccess instellen, dat is misschien ook wel het beste, dan kan het ook in versiebeheer komen: https://gitlab.com/pronamic-websites/selektmeat.nl/-/blob/master/.htaccess

rvdsteege commented 8 months ago

Ik ben geen fan van het instellen van de PHP-versie via .htaccess om twee redenen:

  1. het impliceert dat de te gebruiken PHP-versie op die manier is ingesteld en gebruikt wordt, maar die Apache handler application/x-httpd-php82 is specifiek voor SiteGround en volgt — volgens mij — geen standaard (een andere hosting provider zou de handler bijvoorbeeld application/x-httpd-php8.2 kunnen noemen, als ze überhaupt de moeite hebben genomen om zoiets toe te voegen);
  2. stel dat je nu ergens application/x-httpd-php74 toevoegt en SiteGround verwijdert die PHP-versie en handler, dan gaat de site opeens zonder melding over naar de standaard PHP versie en heeft dat regeltje helemaal geen waarde meer. Ik neem aan dat als de PHP-versie via Site Tools op PHP 7.4 staat ingesteld en ze die versie gaan verwijderen, je daar ook eerst een aankondiging van ontvangt en/of bericht dat de PHP-versie voor die website is gewijzigd. Daarin zal geen rekening gehouden worden met instellingen via .htaccess lijkt mij (of ze moeten alle klanten hetzelfde bericht sturen, ongeacht de instellingen in Site Tools, dan maakt het weinig uit).

Mochten we toch iets met .htaccess bestanden willen doen, dan kunnen we hiervoor misschien ook wel een WP-CLI commando toevoegen aan Pronamic Client? WordPress biedt de functie insert_with_marker( $filename, $marker, $insertion ) dat handig kan zijn voor het wegschrijven naar een .htaccess bestand:

remcotolsma commented 8 months ago

Voor nu is de originele vraag van dit issue wel beantwoord:

Update PHP version via CLI site-tools-client?

De application/x-httpd-php82 notatie wordt wel meer gebruikt:

Maar ideaal is het niet, in SiteTools zie je dan ook PHP 7.4 staan en in de site zelf weer PHP 8.2. https://www.siteground.com/blog/php-7-3/

En met het WP-CLI verhaal erbij blijft het sowieso ook wat buggy.

remcotolsma commented 5 months ago

ℹ️ 🎉 https://www.siteground.com/blog/php-8-2-becomes-default-version

PHP 8.2 Becomes the Default PHP Version on All SiteGround Servers

As of today, PHP 8.2 is the default PHP version on the SiteGround hosting servers. PHP 8.2 has been available on our servers for quite some time, right after its release, and since then anyone was able to use it for their site through our PHP management tool. We are now making it the default PHP since it is already considered fully compatible with all applications on our infrastructure and is the version actively supported by the official PHP developers. Our clients will start enjoying the improved performance and security, as well as the new functionalities included in PHP 8.2 out of the box.

New sites are now created on PHP 8.2

All newly created sites are automatically configured to use PHP 8.2. This ensures that your new projects will take advantage of this PHP version right from their start.

Existing sites WITH Managed PHP service will be gradually updated by us

We are beginning to update all sites using our Managed PHP service to PHP 8.2. We are committed to ensure that this process goes as smoothly as possible and we will provide all the necessary information and support during the transition.

  • You will be notified via email when your site(s) are scheduled for upgrade, giving you enough time to check and test them thoroughly, ensuring they are compatible with PHP 8.2.
  • As part of our Expert Care services you will also be able to request a PHP compatibility check by our experts.
  • Your current PHP version will remain available after the update, so you will be able to revert to it with a click through our PHP management tool if you need more time to work on your site’s compatibility.

Existing sites WITHOUT Managed PHP service should also consider updating

We strongly recommend clients who are not using our Managed PHP service to upgrade to PHP 8.2 manually. PHP versions lower than 8.2 are no longer supported by the official developers and come with a security risk, and/or have reached end of life, which is when we have to remove them from our servers. The oldest PHP version now available on our servers – PHP 7.3 – will be removed in 2025.

Why Upgrade to PHP 8.2?

PHP 8.2 offers a number benefits, that would positively affect your site:

  • PHP 8.2 guarantees faster execution time and reduced resource usage. Compared to PHP 7.4, which was the last default version before 8.2, PHP 8.2 has significantly better performance based on all the benchmark tests we have seen.
  • It offers access to the latest PHP functionalities and improvements, which you may check out in our previous article on the topic written by the PHP Evangelist Cal Evans.
  • Some of the new functionalities, such as the Read-Only properties and Deprecation of Dynamic properties end up generating a more secure code out of the box, which ultimately means a more secure website.
  • It is fully compatible with other software hosted on our platform. All major applications such as WordPress, Joomla, Drupal, etc. have already added support for PHP 8.2.
  • It is considered mature and is the main version actively supported by the PHP core developers, which guarantees it is kept well patched and secure.