Page MenuHomePhabricator

Install PHP-FPM in Wikimedia Italia VPS wmi-fabula (to coexist PHP 5.6 with 7.3)
Closed, ResolvedPublic

Description

Preamble

Wikimedia Italia has a VPS recently called wmi-fabula (Wikimedia Italia server details) running Centos7 and serving lot of websites sharing PHP 5.6 as shared dependency.

Currently it serves nearly 100 virtualhosts (!).

At the time of writing we have an Apache HTTPd configured with the mod_php module.

Proposal

Our VPS should allow to serve websites requiring recent versions of PHP like PHP7 and without impacting in any way legacy websites needing the old PHP 5.6.

This thing is currently not possible and blocks this

Additionally, this forces us to rely on another server belonging to a volunteer to deploy this kind of recent applications.

Also, this feature would also simplify our migrations to recent versions of PHP for our legacy websites. At the time of writing it's difficult (or nearly impossible!) to deal with such bulk migration (again, we have 100 virtualhosts).

Proposed solution

We can achieve the result of supporting two or more PHP versions adopting a recent php-fpm package together with mod_php. This should allow to leave the legacy configurations as-is and just introduce a new virtualhost proxying to the internal PHP-FPM running PHP 7.3.

Event Timeline

valerio.bozzolan renamed this task from Install PHP-FPM in Wikimedia Italia VPS centos01 (to coexist PHP 7.5 and 7.3) to Install PHP-FPM in Wikimedia Italia VPS centos01 (to coexist PHP 5.6 with 7.3).Dec 23 2020, 4:44 PM
valerio.bozzolan triaged this task as Medium priority.
valerio.bozzolan created this task.

Some progresses here.

I was able to install a virtual machine with Centos 7 and see mod_php (PHP 5.6) working alongside with php_fpm (PHP 7.3.20) installing rh-php73-php-fpm and a proxy.

I was following this reference:

https://wiki.centos.org/HowTos/php7

valerio.bozzolan moved this task from In progress to Recent changes on the WMIT-Infrastructure board.

Here the intervention interaction:

$ sudo yum -y install centos-release-scl.noarch
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: ftp.plusline.net
Package centos-release-scl-2-3.el7.centos.noarch already installed and latest version
Nothing to do
$ sudo yum install rh-php73-php-fpm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: ftp.plusline.net
Resolving Dependencies
--> Running transaction check
---> Package rh-php73-php-fpm.x86_64 0:7.3.20-1.el7 will be installed
--> Processing Dependency: rh-php73-php-common(x86-64) = 7.3.20-1.el7 for package: rh-php73-php-fpm-7.3.20-1.el7.x86_64
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: rh-php73-php-fpm-7.3.20-1.el7.x86_64
--> Running transaction check
---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
---> Package rh-php73-php-common.x86_64 0:7.3.20-1.el7 will be installed
--> Processing Dependency: rh-php73-php-json(x86-64) = 7.3.20-1.el7 for package: rh-php73-php-common-7.3.20-1.el7.x86_64
--> Processing Dependency: rh-php73-php-zip(x86-64) = 7.3.20-1.el7 for package: rh-php73-php-common-7.3.20-1.el7.x86_64
--> Processing Dependency: rh-php73-runtime for package: rh-php73-php-common-7.3.20-1.el7.x86_64
--> Running transaction check
---> Package rh-php73-php-json.x86_64 0:7.3.20-1.el7 will be installed
---> Package rh-php73-php-zip.x86_64 0:7.3.20-1.el7 will be installed
---> Package rh-php73-runtime.x86_64 0:1-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
 Package                                                  Arch                                        Version                                            Repository                                           Size
===================================================================================================================================================================================================================
Installing:
 rh-php73-php-fpm                                         x86_64                                      7.3.20-1.el7                                       centos-sclo-rh                                      1.5 M
Installing for dependencies:
 pcre2                                                    x86_64                                      10.23-2.el7                                        base                                                201 k
 rh-php73-php-common                                      x86_64                                      7.3.20-1.el7                                       centos-sclo-rh                                      686 k
 rh-php73-php-json                                        x86_64                                      7.3.20-1.el7                                       centos-sclo-rh                                       54 k
 rh-php73-php-zip                                         x86_64                                      7.3.20-1.el7                                       centos-sclo-rh                                       90 k
 rh-php73-runtime                                         x86_64                                      1-1.el7                                            centos-sclo-rh                                      1.1 M

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 3.6 M
Installed size: 12 M
Is this ok [y/d/N]:
$ y
Downloading packages:
(1/6): pcre2-10.23-2.el7.x86_64.rpm                                                                                                                                                         | 201 kB  00:00:00     
(2/6): rh-php73-php-json-7.3.20-1.el7.x86_64.rpm                                                                                                                                            |  54 kB  00:00:00     
(3/6): rh-php73-php-zip-7.3.20-1.el7.x86_64.rpm                                                                                                                                             |  90 kB  00:00:00     
(4/6): rh-php73-php-common-7.3.20-1.el7.x86_64.rpm                                                                                                                                          | 686 kB  00:00:00     
(5/6): rh-php73-php-fpm-7.3.20-1.el7.x86_64.rpm                                                                                                                                             | 1.5 MB  00:00:00     
(6/6): rh-php73-runtime-1-1.el7.x86_64.rpm                                                                                                                                                  | 1.1 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                              4.7 MB/s | 3.6 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-php73-runtime-1-1.el7.x86_64                                                                                                                                                                 1/6 
  Installing : rh-php73-php-zip-7.3.20-1.el7.x86_64                                                                                                                                                            2/6 
  Installing : rh-php73-php-common-7.3.20-1.el7.x86_64                                                                                                                                                         3/6 
  Installing : rh-php73-php-json-7.3.20-1.el7.x86_64                                                                                                                                                           4/6 
  Installing : pcre2-10.23-2.el7.x86_64                                                                                                                                                                        5/6 
  Installing : rh-php73-php-fpm-7.3.20-1.el7.x86_64                                                                                                                                                            6/6 
  Verifying  : pcre2-10.23-2.el7.x86_64                                                                                                                                                                        1/6 
  Verifying  : rh-php73-php-json-7.3.20-1.el7.x86_64                                                                                                                                                           2/6 
  Verifying  : rh-php73-runtime-1-1.el7.x86_64                                                                                                                                                                 3/6 
  Verifying  : rh-php73-php-zip-7.3.20-1.el7.x86_64                                                                                                                                                            4/6 
  Verifying  : rh-php73-php-common-7.3.20-1.el7.x86_64                                                                                                                                                         5/6 
  Verifying  : rh-php73-php-fpm-7.3.20-1.el7.x86_64                                                                                                                                                            6/6 

Installed:
  rh-php73-php-fpm.x86_64 0:7.3.20-1.el7                                                                                                                                                                           

Dependency Installed:
  pcre2.x86_64 0:10.23-2.el7      rh-php73-php-common.x86_64 0:7.3.20-1.el7      rh-php73-php-json.x86_64 0:7.3.20-1.el7      rh-php73-php-zip.x86_64 0:7.3.20-1.el7      rh-php73-runtime.x86_64 0:1-1.el7     

Complete!

$ yum install rh-php73-php-mysqlnd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: mirror.init7.net
Resolving Dependencies
--> Running transaction check
---> Package rh-php73-php-mysqlnd.x86_64 0:7.3.20-1.el7 will be installed
--> Processing Dependency: rh-php73-php-pdo(x86-64) = 7.3.20-1.el7 for package: rh-php73-php-mysqlnd-7.3.20-1.el7.x86_64
--> Running transaction check
---> Package rh-php73-php-pdo.x86_64 0:7.3.20-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                        Arch             Version                 Repository                Size
========================================================================================================
Installing:
 rh-php73-php-mysqlnd           x86_64           7.3.20-1.el7            centos-sclo-rh           165 k
Installing for dependencies:
 rh-php73-php-pdo               x86_64           7.3.20-1.el7            centos-sclo-rh           100 k

Transaction Summary
========================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 265 k
Installed size: 609 k
Is this ok [y/d/N]:
$ y
Downloading packages:
(1/2): rh-php73-php-pdo-7.3.20-1.el7.x86_64.rpm                                  | 100 kB  00:00:00     
(2/2): rh-php73-php-mysqlnd-7.3.20-1.el7.x86_64.rpm                              | 165 kB  00:00:00     
--------------------------------------------------------------------------------------------------------
Total                                                                   697 kB/s | 265 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-php73-php-pdo-7.3.20-1.el7.x86_64                                                 1/2 
  Installing : rh-php73-php-mysqlnd-7.3.20-1.el7.x86_64                                             2/2 
  Verifying  : rh-php73-php-pdo-7.3.20-1.el7.x86_64                                                 1/2 
  Verifying  : rh-php73-php-mysqlnd-7.3.20-1.el7.x86_64                                             2/2 

Installed:
  rh-php73-php-mysqlnd.x86_64 0:7.3.20-1.el7                                                            

Dependency Installed:
  rh-php73-php-pdo.x86_64 0:7.3.20-1.el7                                                                

Complete!

$ yum install rh-php73-php-mbstring
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: mirror.init7.net
Resolving Dependencies
--> Running transaction check
---> Package rh-php73-php-mbstring.x86_64 0:7.3.20-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                         Arch             Version                Repository                Size
========================================================================================================
Installing:
 rh-php73-php-mbstring           x86_64           7.3.20-1.el7           centos-sclo-rh           592 k

Transaction Summary
========================================================================================================
Install  1 Package

Total download size: 592 k
Installed size: 1.6 M
Is this ok [y/d/N]:
$ y
Downloading packages:
rh-php73-php-mbstring-7.3.20-1.el7.x86_64.rpm                                    | 592 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-php73-php-mbstring-7.3.20-1.el7.x86_64                                            1/1 
  Verifying  : rh-php73-php-mbstring-7.3.20-1.el7.x86_64                                            1/1 

Installed:
  rh-php73-php-mbstring.x86_64 0:7.3.20-1.el7                                                           

Complete!

$ yum install rh-php73-php-gd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: ftp.plusline.net
Resolving Dependencies
--> Running transaction check
---> Package rh-php73-php-gd.x86_64 0:7.3.20-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                    Arch              Version                   Repository                 Size
========================================================================================================
Installing:
 rh-php73-php-gd            x86_64            7.3.20-1.el7              centos-sclo-rh            150 k

Transaction Summary
========================================================================================================
Install  1 Package

Total download size: 150 k
Installed size: 383 k
Is this ok [y/d/N]:
$ y
Downloading packages:
rh-php73-php-gd-7.3.20-1.el7.x86_64.rpm                                          | 150 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-php73-php-gd-7.3.20-1.el7.x86_64                                                  1/1 
  Verifying  : rh-php73-php-gd-7.3.20-1.el7.x86_64                                                  1/1 

Installed:
  rh-php73-php-gd.x86_64 0:7.3.20-1.el7                                                                 

Complete!

$ yum install -y rh-php73-php-dom
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.standaloneinstaller.com
 * centos-sclo-sclo: mirrors.standaloneinstaller.com
 * epel: mirror.init7.net
Resolving Dependencies
--> Running transaction check
---> Package rh-php73-php-xml.x86_64 0:7.3.20-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                     Arch              Version                  Repository                 Size
========================================================================================================
Installing:
 rh-php73-php-xml            x86_64            7.3.20-1.el7             centos-sclo-rh            158 k

Transaction Summary
========================================================================================================
Install  1 Package

Total download size: 158 k
Installed size: 411 k
Downloading packages:
rh-php73-php-xml-7.3.20-1.el7.x86_64.rpm                                         | 158 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rh-php73-php-xml-7.3.20-1.el7.x86_64                                                 1/1 
  Verifying  : rh-php73-php-xml-7.3.20-1.el7.x86_64                                                 1/1 

Installed:
  rh-php73-php-xml.x86_64 0:7.3.20-1.el7                                                                

Complete!

$ systemctl enable --now rh-php73-php-fpm

It seems it's working.

To use this, just add something as this in your Apache HTTPd virtualhost:

        #
	# We are using the Centos 7 package 'rh-php72-php-fpm'
        #
	# See https://phabricator.wikimedia.org/T270776
        #
	ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/project
valerio.bozzolan renamed this task from Install PHP-FPM in Wikimedia Italia VPS centos01 (to coexist PHP 5.6 with 7.3) to Install PHP-FPM in Wikimedia Italia VPS wmi-fabula (to coexist PHP 5.6 with 7.3).Jan 20 2021, 9:56 AM
valerio.bozzolan updated the task description. (Show Details)

In Centos 7 PHP sessions are broken.

Issued:

mkdir        /var/lib/php/session
chown apache /var/lib/php/session

Holy shit I hate Centos 7.

To avoid mistake I've disabled this service:

systemctl mask php-fpm.service
WARNING: ALWAYS START THE rh-php73-php-fpm service and not the php-fpm service!