Multiple versions of php on nginx, but doesn't need to be simultaneous

Ok, I’ve read some tutorials/instructions to run multiple versions of php on the same server (linux, fedora). They’re kinda complicated, I mean I can handle it (I’ve been installing servers and writing php for 15 years), but, for my development purposes I don’t need anything fancy, this is just for a development LAN server so my question is:

It must be simpler to run php versions as an either-or right? So for example, can I install 7.1 and 5.6 and then just change the nginx conf file and just systemctl restart nginx to switch between the two? (well, or apache httpd.conf if I’m running apache)? It seems like that’d be trivially easy to change right, just take out a comment hashtag in the conf and add one whenever I need to switch projects.

That would work fine for me and it must be easier, no? Hell, I could probably even install them both in mod_, but I don’t really even need that, I’m fine with old-fashioned cgi - I mean these are just development and stage servers, so, no load. The php code would be the same in either environment, right.

So, I’ve read these threads:

And most tutorials I’ve read focus on windows and/or focus on running them simultaneously.

Can you give me a rundown on how to install and configure both with dnf and then switch them in the conf’s for apache and nginx?


Not positive what you are asking so I could be completely off base here.

For nginx I can specify the php version to use inside of the location in my server block:

location ~ ^/index\.php(/|$) {
	include snippets/fastcgi-php.conf;
	fastcgi_pass unix:/run/php/php7.2-fpm.sock;
	fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
	fastcgi_param DOCUMENT_ROOT   $realpath_root;
	fastcgi_param APP_ENV prod;

I can of course adjust the php fpm version to what I need. Does that help at all?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.