How to use same PHP and MySQL for all applications with SSH

one text

I have installed WordPress in example.com. When i install WordPress it automatically install all dependencies like PHP, MySQL, Apache/nginx, etc

Now, I have installed iRedMail in example.com/email and it will again install PHP, MySQL, Apache/nginx, etc in sub-folder /email

Again, i am installing RoundCube in example.com/mail and it will again install dependency for roundcube like PHP, MySQL, Apache/nginx, etc in another sub folder /mail

The issues is, this consume more space because PHP, MySQL, etc getting installed 3 times and also it will make performance slow as 3 PHP services running.

How can i install PHP, MySQL, Apache/nginx, and other dependency in one folder example /dependency and use it with all my applications without installing same again and again?

Source