Content
- page: Installing the sury.org repository and installing various PHP versions
- page: Combined use of different PHP-FPM versions on a single server
The 1. page content
Introductory
Debian 9 (Stretch) is official in the trunk a PHP 7.0.x version is availablewhich is already over time went by a bitand you will no longer receive updates. Therefore, we may need newer versions if we run live websites, but we can even expand our test environment. We’ve dealt with compiling PHP from source before Debian to 8 and Debian to 9 also, now the deb.sury.org using our external repository, we will conveniently install several PHP versions, including PHP-FPM can be used side by side on Debian 9 (Stretch), Debian 8 (Jessie) or even Debian 10 (Buster) with the server API.
The deb.sury.org repository is unofficial Debian package store, but its maintainer (Ondřej Surý) has been building PHP packages into Debian 's official repository since PHP 5, so we can safely use the latest versions of PHP and other add - ons on his Debian or Ubuntu server. An additional benefit of using the repo is that newer packages are added to our system from time to time APT it is easy to update with the package manager.
basic Conditions
You need at least one to make this recipe Apache web server to retrieve php output from the server (PHP will be installed in this tutorial, of course).
If we start with a minimal server, such as one of the following:
- Debian 8 (Jessie) is a minimal server
- Debian 9 (Stretch) is a minimal server
- Debian 10 (Buster) is a minimal server
then install Apache (as root) using the following command:
apt-get -y install apache2
Or we can start one With the LAMP system which also include Apache in addition to Apache MySQL / MariaDB database server and basic PHP:
As the title of the description suggests, I will do this task on the Debian 9 (Stretch) LAMP server, so we will be able to build more on this server later.
Deploying the deb.sury.org repository
First, install some required packages:
apt-get install -y apt-transport-https ca-certificates
Az apt-transport-https package allows us to use it in our APT source list HTTPS available libraries. THE ca-certificates and contains a list of trusted certificate authorities that SSL applications can verify the authenticity of SSL connections.
Once you're done, log in to your luggage GPG keys storage directory:
cd /etc/apt/trusted.gpg.d/
Then download the GPG key of sury.org into this directory, named by some name (with the -O switch) so that we can later know whose GPG key it is:
wget https://packages.sury.org/php/apt.gpg -O sury-org-php.gpg
Then open our APT source file for editing:
nano /etc/apt/sources.list
Then add the line corresponding to our main Debian version:
deb https://packages.sury.org/php/ <Debian kódnevünk> main
Where to replace our Debian code name as follows (in lower case):
- For Debian 8: "Jessie"
- For Debian 9: "Stretch"
- For Debian 10: "buster"
- For Debian 11: "bull's eye"
(Make sure there are spaces before and after the code name.)
Save the file and update our libraries:
apt-get update
apt-get -y upgrade
At the beginning of the update, it announces that some packages will be withheld. For example:
Az alábbi csomagok vissza lesznek tartva: libapache2-mod-php7.0 libxml2 linux-image-amd64 php-bz2 php-mbstring php-mysql php-xml php7.0-bz2 php7.0-cli php7.0-common php7.0-curl php7.0-gd php7.0-imap php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-pspell php7.0-readline php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xml php7.0-xmlrpc php7.0-zip
If you would like to upgrade any of these withheld packages, please see the following link for implementation:
How to update our hold packages using the APT package manager
As our goal is to add newer versions of PHP7.0, so we are not dealing with 7.0, but we are starting to install newer versions of PHP.
Install PHP versions
You can install several versions of PHP from the sury.org repository, currently 5.6, 7.0, 7.1, 7.2, 7.3 and 7.4. Suppose these are the ones we need, but we can even assume all of them.
basic Packages
Before installing the different versions of PHP, it is a good idea to install some basic packages that provide the necessary additional features for each version of PHP.
The command includes the installation of several packages, so I display them in separate lines, which can be run copied at once
apt-get -y install \
mcrypt \
imagemagick \
memcached \
php-apcu \
php-gettext \
php-imagick \
php-memcache \
php-pear \
php-yaml
Then you can install different versions of PHP.
PHP 5.6
Although this is an older version, but if you already have it in the new repository and need it, eg. to run an old website, install it with the following command:
apt-get -y install \
php5.6 \
php5.6-bcmath \
php5.6-bz2 \
php5.6-cgi \
php5.6-cli \
php5.6-common \
php5.6-curl \
php5.6-fpm \
php5.6-gd \
php5.6-imap \
php5.6-intl \
php5.6-json \
php5.6-mbstring \
php5.6-mcrypt \
php5.6-mysql \
php5.6-opcache \
php5.6-pspell \
php5.6-recode \
php5.6-soap \
php5.6-sqlite3 \
php5.6-tidy \
php5.6-xml \
php5.6-xmlrpc \
php5.6-xsl \
php5.6-zip
At the end of the command, it writes a few lines of comment:
NOTICE: Not enabling PHP 5.6 FPM by default. NOTICE: To enable PHP 5.6 FPM in Apache2 do: NOTICE: a2enmod proxy_fcgi setenvif NOTICE: a2enconf php5.6-fpm NOTICE: You are seeing this message because you have apache2 package installed.
In short, PHP-FPM is not enabled by default in Apache, you need to enable the appropriate modules to use it. These will be set later.
This compilation includes the components of a general-purpose PHP system, but if you need more packages, here are the ones apt-cache command to search for all PHP 5.6 packages:
apt-cache search php5.6
From the list you can still make raisins if you need other accessories.
We can check this version with the CLI:
php5.6 --version
PHP 5.6.40-12+0~20190902.20+debian9~1.gbpc72558 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
So if you need the command line mode of PHP 5.6, eg. to perform a cron task, etc, then a php5.6 command can be used for this version.
The php.ini files are located in the following locations:
- CLI: /etc/php/5.6/cli/php.ini
- PHP-FPM offer: /etc/php/5.6/fpm/php.ini
Query PHP-FPM Status:
systemctl status php5.6-fpm
● php5.6-fpm.service - The PHP 5.6 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php5.6-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 19:55:19 CEST; 2h 1min ago
Docs: man:php-fpm5.6(8)
Main PID: 21398 (php-fpm5.6)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/php5.6-fpm.service
├─21398 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
├─21400 php-fpm: pool www
└─21401 php-fpm: pool www
szept 26 19:55:19 debian9 systemd[1]: Starting The PHP 5.6 FastCGI Process Manager...
szept 26 19:55:19 debian9 systemd[1]: Started The PHP 5.6 FastCGI Process Manager.
PHP 7.0
If you are not already up and you need 7.0 PHP for compatibility reasons, install it with the following command:
apt-get -y install \
php7.0 \
php7.0-bcmath \
php7.0-bz2 \
php7.0-cgi \
php7.0-cli \
php7.0-common \
php7.0-curl \
php7.0-fpm \
php7.0-gd \
php7.0-imap \
php7.0-intl \
php7.0-json \
php7.0-mbstring \
php7.0-mcrypt \
php7.0-mysql \
php7.0-opcache \
php7.0-pspell \
php7.0-recode \
php7.0-soap \
php7.0-sqlite3 \
php7.0-tidy \
php7.0-xml \
php7.0-xmlrpc \
php7.0-xsl \
php7.0-zip
It will post comments on PHP-FPM here, but from now on I will not provide the scope of the description ...
Here you can also search for the packages you need by using the following command:
apt-cache search php7.0
Command line usage: php7.0
The php.ini files:
- CLI: /etc/php/7.0/cli/php.ini
- PHP-FPM offer: /etc/php/7.0/fpm/php.ini
Query PHP-FPM Status:
systemctl status php7.0-fpm
● php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 20:28:22 CEST; 1h 31min ago
Docs: man:php-fpm7.0(8)
Main PID: 28253 (php-fpm7.0)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/php7.0-fpm.service
├─28253 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
├─28254 php-fpm: pool www
└─28255 php-fpm: pool www
szept 26 20:28:22 debian9 systemd[1]: Starting The PHP 7.0 FastCGI Process Manager...
szept 26 20:28:22 debian9 systemd[1]: Started The PHP 7.0 FastCGI Process Manager.
PHP 7.1
You can also install the 7.1 branch in the same way:
apt-get -y install \
php7.1 \
php7.1-bcmath \
php7.1-bz2 \
php7.1-cgi \
php7.1-cli \
php7.1-common \
php7.1-curl \
php7.1-fpm \
php7.1-gd \
php7.1-imap \
php7.1-intl \
php7.1-json \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-mysql \
php7.1-opcache \
php7.1-pspell \
php7.1-recode \
php7.1-soap \
php7.1-sqlite3 \
php7.1-tidy \
php7.1-xml \
php7.1-xmlrpc \
php7.1-xsl \
php7.1-zip
Here you can search for other add-ons similar to the search command above ...
Command line usage: php7.1
The php.ini files:
- CLI: /etc/php/7.1/cli/php.ini
- PHP-FPM offer: /etc/php/7.1/fpm/php.ini
Query PHP-FPM Status:
systemctl status php7.1-fpm
● php7.1-fpm.service - The PHP 7.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 20:54:00 CEST; 1h 10min ago
Docs: man:php-fpm7.1(8)
Main PID: 11156 (php-fpm7.1)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/php7.1-fpm.service
├─11156 php-fpm: master process (/etc/php/7.1/fpm/php-fpm.conf)
├─11158 php-fpm: pool www
└─11159 php-fpm: pool www
szept 26 20:54:00 debian9 systemd[1]: Starting The PHP 7.1 FastCGI Process Manager...
szept 26 20:54:00 debian9 systemd[1]: Started The PHP 7.1 FastCGI Process Manager.
PHP 7.2
To install 7.2 PHP, run the following:
apt-get -y install \
php7.2 \
php7.2-bcmath \
php7.2-bz2 \
php7.2-cgi \
php7.2-cli \
php7.2-common \
php7.2-curl \
php7.2-fpm \
php7.2-gd \
php7.2-imap \
php7.2-intl \
php7.2-json \
php7.2-mbstring \
php7.2-mysql \
php7.2-opcache \
php7.2-pspell \
php7.2-recode \
php7.2-soap \
php7.2-sqlite3 \
php7.2-tidy \
php7.2-xml \
php7.2-xmlrpc \
php7.2-xsl \
php7.2-zip
Command line usage: php7.2. Ex. Version query:
php7.2 --version
The php.ini files:
- CLI: /etc/php/7.2/cli/php.ini
- PHP-FPM offer: /etc/php/7.2/fpm/php.ini
Query PHP-FPM Status:
systemctl status php7.2-fpm
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 21:17:17 CEST; 49min ago
Docs: man:php-fpm7.2(8)
Main PID: 29395 (php-fpm7.2)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/php7.2-fpm.service
├─29395 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
├─29396 php-fpm: pool www
└─29397 php-fpm: pool www
szept 26 21:17:17 debian9 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
szept 26 21:17:17 debian9 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.
PHP 7.3
You can install 7.3 PHP similarly:
apt-get -y install \
php7.3 \
php7.3-bcmath \
php7.3-bz2 \
php7.3-cgi \
php7.3-cli \
php7.3-common \
php7.3-curl \
php7.3-fpm \
php7.3-gd \
php7.3-imap \
php7.3-intl \
php7.3-json \
php7.3-mbstring \
php7.3-mysql \
php7.3-opcache \
php7.3-pspell \
php7.3-recode \
php7.3-soap \
php7.3-sqlite3 \
php7.3-tidy \
php7.3-xml \
php7.3-xmlrpc \
php7.3-xsl \
php7.3-zip
Command line usage: php7.3. Ex. Version query:
php7.3 --version
The php.ini files:
- CLI: /etc/php/7.3/cli/php.ini
- PHP-FPM offer: /etc/php/7.3/fpm/php.ini
Query PHP-FPM Status:
systemctl status php7.3-fpm
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 21:50:42 CEST; 18min ago
Docs: man:php-fpm7.3(8)
Main PID: 13594 (php-fpm7.3)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 4915)
CGroup: /system.slice/php7.3-fpm.service
├─13594 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
├─13595 php-fpm: pool www
└─13596 php-fpm: pool www
szept 26 21:50:42 debian9 systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
szept 26 21:50:42 debian9 systemd[1]: Started The PHP 7.3 FastCGI Process Manager.
PHP 7.4
And finally, to install the current latest PHP version:
apt-get -y install \
php7.4 \
php7.4-bcmath \
php7.4-bz2 \
php7.4-cgi \
php7.4-cli \
php7.4-common \
php7.4-curl \
php7.4-fpm \
php7.4-gd \
php7.4-imap \
php7.4-intl \
php7.4-json \
php7.4-mbstring \
php7.4-mysql \
php7.4-opcache \
php7.4-pspell \
php7.4-soap \
php7.4-sqlite3 \
php7.4-tidy \
php7.4-xml \
php7.4-xmlrpc \
php7.4-xsl \
php7.4-zip
Command line usage: php7.4. Ex. Version query:
php7.4 --version
PHP 7.4.0beta4 (cli) (built: Aug 27 2019 13:24:38) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies with Zend OPcache v7.4.0beta4, Copyright (c), by Zend Technologies
As you can see, PHP 7.4 - at the time of writing (2019-09-27) - is still in beta, so don’t use it in a live environment yet. On this change a PHP official site get information.
Rounding out the 4 months since writing this description, PHP 7.4 mentioned above is currently:
PHP 7.4.2 (cli) (built: Jan 23 2020 14:09:40) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
Based on this, you can see that PHP 7.4 has undergone a major development, so now you can use it for live use.
The php.ini files are:
- CLI: /etc/php/7.4/cli/php.ini
- PHP-FPM offer: /etc/php/7.4/fpm/php.ini
Query PHP-FPM Status:
systemctl status php7.4-fpm
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-09-26 22:20:01 CEST; 6min ago
Docs: man:php-fpm7.4(8)
Main PID: 30857 (php-fpm7.4)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/php7.4-fpm.service
├─30857 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
├─30858 php-fpm: pool www
└─30859 php-fpm: pool www
szept 26 22:20:01 debian9 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
szept 26 22:20:01 debian9 systemd[1]: Started The PHP 7.4 FastCGI Process Manager.
An independent Based on PHP test the performance of the 7.4 branch looks promising, so we are waiting for the stable release as soon as possible.
As you can see, the FPM pools of the different PHP versions have been started, with the default process of 1 + 2 per head waiting for incoming connections. However, our task is not over here, the next page we continue with the parallel use of PHP on a server.
PHP 8.0
PHP 8 installation description completed:
Related Content, Useful Links:
- Encyclopedia - PHP
- Encyclopedia - PHP-FPM
- How to install PHP 8 on your Debian or Ubuntu server
- How to install PHP-FPM on a Debian 8 (Jessie) LAMP server
- How to install PHP 7.1.19 in optional mode on Debian 8 perfect server
- How to install PHP 5.6.40 as an optional version on Debian 9 (Stretch) perfect server
- How to configure custom PHP versions on our ISPConfig server
- How to manually change the PHP version of a website or web application running in a PHP-FPM pool?
- What's new and changed in PHP 8
- Download the perfect server: Debian 10 (Buster) v1.1
- What if our Sury.org repository is not updated due to a GPG signing error on our Debian server?
Navigation
- To post registration and login required
- 1193 views