Instead of installing all packages to system with risk of breaking something, i would suggest to use apps as containers.
For example using php as runtime with option to enable extensions, it will then run docker as runtime.
When creating website, it will be possible to choose if i want runtime(php) to website. While creating website, if choosen php, it will use this php container. Of course it will be needed to bind volume for config editing etc, but it will me much easier to maintenance it!
As for using app likle database, it will be even easier, just run it and done.
Using apps as docker containers would be much much better.
I would recommend to use some from bitnami like mysql, mariadb, phpmyadmin etc
as for php, using official with some additional dockerfile for using it with enabling extensions.
For example using image with all extensions with option to enable/disable of some extensions,
or using image with no extensions for performance gains and when enabling/disabling some extensions, it will rebuild image(still faster than building whole php). I would recommend the latter one.
In summary, converting installation of apps to using those apps from docker, would be much better imo
Recently i found out some panel named 1panel which had such a feature of using php as container for website engine which was in container too and it was awesome. Still i prefer aapanel thats why i suggest some changes.
We should always look for better changes.
Maintenance would be easier too, and there would be less problems from customers!