Skip to main content

Run multiple PHP version on Ubuntu, Apache2 and Nginx

Notes some problems on run more than one PHP version on Ubuntu.
There are still some questions about how PHP, PHP CLI, Web Server Apache2, Nginx, PHP-FPM (FastCGI), composer ...

Switch PHP version with Apache2
https://askubuntu.com/questions/761713/how-can-i-downgrade-from-php-7-to-php-5-6-on-ubuntu-16-04

https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/

The basic idea for run 2 (or more ?) PHP version with Nginx and PHP-FPM is each FPM run on different port (9000, 9001) if use TCP/IP mode.
In case use eg. php5-fpm.sock then you can point to different php-version.sock

Keyword "Pool", Each pool for each PHP, FPM version seem have to different.
If you use default pool (www) then I see that php-fpm only run for one version ie. php7.0-fpm while php5-fpm CGI not run.

Use PHP7 with apache2 and PHP5 with Nginx.

Apache2 can be switch PHP version by a2enmod, dismod to use PHP module.
PHP with Apache is module. PHP in CLI is different story.
This will affect composer.
So we have to really understand the way language, PHP processor, Linux and Web server work.

Install different version
https://www.tecmint.com/install-different-php-versions-in-ubuntu/

Set default PHP version in Ubuntu
------------ Set Default PHP Version 5.6 ------------
$ sudo update-alternatives --set php /usr/bin/php5.6

https://www.tecmint.com/install-different-php-versions-in-ubuntu/


Update 1:
When switch/set default PHP version both APC and nginx, after that we have to install and / or remove some lib like php-mysql, curl ... I don't know why default or php7.0 mysql is lost.
So after switch to 5.6 for example and back, server not work as before.
After many trial and error I figure out that it is caused by mis lib php-mysql The common when install php.

It is pschological that prevent me to clear on investigate problem.
PS: Remember update port 9000 in ie. php/5.6/fpm/pool.d/www.conf etc

In real situation it easier to expose problems. If we trying to test multiple version affect, it require a clever setup both multi project cover as much problems as posible.

Comments

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe