I agree!
The main “apt-get install” line could use all non-version specific package names like so
sudo apt-get install -y php-gd php-opcache php-curl php-pear php-dev php-mcrypt php-common php-mbstring
They all (except mcrypt?) have virtual or dependency packages to facilitate this
php-gd
php-opcache
php-curl php-dev
php-common
php-mbstring
as does php-mysql and php. It seems only php-mcrypt doesn’t have a package for php7.3/Buster.
(all the links above are to the Stretch packages, use the release selector at the top right to view Buster versions)
Also there isn’t any need for the
sudo apt-get install -y libapache2-mod-php
as that is a dependency of php, so whether apache2 is installed or not, the libapache2-mod-php package will get installed with php.
The mariadb-client package is the default for either Buster or Stretch, since the “mysql-client” package in Stretch installs the " default-mysql-client" which is mariadb, so again both can use “mariadb-client”
So the only place the installers would differ then is in the paths for the extensions to be installed to, and once the package installer has been used to install “php” it is easy to query what has been installed and use that in the path eg
PHP_VER=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." )
then
printf "extension=mosquitto.so" | sudo tee /etc/php/${PHP_VER}/mods-available/mosquitto.ini 1>&2
or
printf "extension=redis.so" | sudo tee /etc/php/${PHP_VER}/mods-available/redis.ini 1>&2
I have a 4GB Pi4 here but I haven’t tried emoncms or emonSD etc yet.