As you probably know it’s possible to install multiple versions of PHP on one server. For web servers, simply define which PHP version you want to use in your server’s configuration file. But how to do it for PHP cli?
Actually I won’t get into details with Varnish and Nginx configuration because it really depends on your particular case. But it should be pretty straight forward as installing default packages:
apt install varnish
apt install nginx
I’m using port 443 for SSL services, so HAProxy is using this one. It also uses HTTP port 80 and redirects that to https. Everybody knows that Haproxy is stable and quick in jobs it does and that’s load balancing and proxying traffic. In our case, we are going to use it for SSL termination and forward traffic to Varnish which is going to occupy port 6081 (default). And Nginx will use port 8080 because it’s the final destination in our setup. Varnish should cache most of the web content and hopefully put our dedicated server’s CPU at ease most of the time and leverage quite slow CPU to a large amount of RAM (128GB).
In case of traffic increase we can easily balance our traffic to other servers behind Varnish, because Varnish can play a load-balancing role as well.