Reputation: 1001
I'm using ubuntu 16.0.4 having nginx and php7.0-fpm installed on it. Is it possible to use another version of php for another project at the same time?
How should I change my nginx config file?
Upvotes: 0
Views: 1257
Reputation: 11
It might be a good idea to consider using Docker for this. Even if it is possible to have multiple versions of PHP on the same server.
Docker is an elegant system which allows you to run multiple instances of operating systems at the same time without the drawbacks of virtual machines.
Why run multiple operating systems? If you have a situation where you need to have a certain version of PHP for one project and another version for another project, then you could create two Docker "containers" which would be two separate Ubuntu environments where nginx can be configured to work for each project separately.
The main advantage is that there is no possibility of breaking one project while working on the other. You can safely customise your nginx server for whatever bazaar requirements any project might have. You can also copy a container so that multiple people can all work with exactly the same Ubuntu environment with the same versions and configuration files for everything.
It might sound inefficient, but its not:
Upvotes: 1
Reputation: 3559
I usualy change the fastcgi_pass socket variable into my nginx conf file.
location ~ \.php$ {
...
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
....
}
Check the sock location for your php version. Mine (using Debian 9) can be located into /var/run/php/
cd /var/run/php
I currently have both php fpm 5.6 and 7.2 installed on my system, and the list command will output both php5.6-fpm.sock and php7.2-fpm.sock files.
You could then substitute the sock pointer into the nginx file:
location ~ \.php$ {
...
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
....
}
Remember to reload nginx afterwards:
sudo systemctl restart nginx
Upvotes: 0
Reputation: 1
Maybe you could try to use Docker or Vagrant. Or try this: https://tecadmin.net/install-multiple-php-version-nginx-ubuntu/
Upvotes: 0