2

The following question is a follow up to this question.

Each time I create a Debian server environment to host my own websites on I install latest yet stable php with different extensions (subpackages); these extensions are needed for some GUIs like PHPMyAdmin or some CMSs like Drupal.

I'm fed up with tracking packages for any latest php install (sometimes some packages are added and some are deprecated).

How could I install only the latest php with all its available packages whatsoever?

  • As you put emphasis on latest – which bleeding edge repository are you using? In pure Debian, php-mbstring is a redirection to php7.3-mbstring, which represents the latest version packaged for you. – Hermann Mar 2 at 10:09
  • I mean to latest-stable versions; I added a link to the question that the current question aims to follow, to better explain what I aspire to have. I just desire to install a latest-stable php package (7.x.x now or 8.x.x at the time when it comes out) but with all its possible extensions). – JohnDoea Mar 2 at 10:14
  • Out of ignorance, are the dependent packages/extensions not declared as requisites for the phpmyadmin or drupal packages? Just want to rule out the simplest idea of apt install drupal phpmyadmin – Jeff Schaller Mar 2 at 12:39
  • Some are declared as requisites, but given it changes and I prefer not to follow the changes for PHP extensions, I just want to install all of them, as I have 40GB drive it should be okay as long as security is part of the picture. I guess. – JohnDoea Mar 2 at 15:48
3
+50

You could use the following to install the current versions of all the PHP packages provided provided by php-defaults:

apt install $(grep-aptavail -S php-defaults -s Package -n)

(You’ll need to install dctrl-tools first.)

This uses two commands:

grep-aptavail -S php-defaults -s Package -n

searches the packages apt knows about, looking for a source package (-S) matching “php-defaults”, and listing matching binary packages (-s Package) without the field name (-n); the result is used, via command substitution, as arguments to

apt install

which installs the packages.

This will install the default version of PHP and all the extensions provided by PHP, and ensure that they are upgraded as new versions become the default (so when you upgrade from Debian 9 to Debian 10, and PHP 7.3 becomes the default instead of PHP 7.0, all your PHP 7.0 extensions will be upgraded to 7.3). However you’d need to re-run the command to pick up new extensions, and clean up obsolete ones separately.

You could adapt this to install every package which depends on php-common, which would bring in all the available PHP extensions, but that ends up installing far more packages than makes sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.