Use more then one PHP version in Nginx

In many cases probably you need to have different PHP version on the same machine and using it on different domains.

Install PHP

You can install PHP versions by downloading already compiled package or you can compile your own (with personalized configuration – quick php compile & install guide).

Personally, I prefer for development machines to compile php by myself.  You can read how I prefer to install php in linked before article.

PHP FPM

In you php-fpm coffiguration file there is a option to specify the port used to listen:

Nginx

Next step in your configuration is to define the upstream  in nginx configuration to be able to pass the request to PHP.  Next you will have few examples:

Next time when you will configure a virtual host on your machine you will be able to use different php version on the same machine: