GNU/Linux >> LINUX-Kenntnisse >  >> Debian

So installieren Sie PHP 5.6 und 7.0 - 8.1 als PHP-FPM &FastCGI für ISPConfig 3 mit apt auf Debian 8 bis 11

Dieses Tutorial zeigt, wie man mehrere PHP-Versionen auf einem ISPConfig-Debian-Server installiert. Die PHP-Version kann später in den Website-Einstellungen von ISPConfig 3 für jede Website einzeln ausgewählt werden. Diese Funktion funktioniert mit PHP-FPM und FastCGI. Wir werden PHP 5.6, 7.x und 8.x als PHP-FPM und eine FastCGI-Version auf einem Debian-Server installieren, indem wir die PHP-Pakete von sury.org verwenden.

1 Vorbemerkung

Ich werde PHP mit apt-get direkt von der Website des Betreuers des Debian-PHP-Pakets https://packages.sury.org/php/ installieren. Dies überschreibt nicht die vorhandene Installation, sondern ändert die standardmäßig verwendete PHP-Version auf die neuste installierte! Daher ist es sehr wichtig, eine neue PHP-Version für die installierte Version zu ISPConfig hinzuzufügen und zuerst alle Seiten auf diese Version umzustellen. Wenn Sie Cron-Jobs verwenden, die PHP-Skripte aufrufen, müssen Sie diese ebenfalls anpassen, dazu später mehr.

Da auch andere Pakete wie openssl aktualisiert werden, können die installierten Pakete von sury.org nach der Installation nicht einfach entfernt werden. Sie müssen diese Pakete zuerst auf die Debian-Versionen herunterstufen, bevor Sie die PHP-Pakete entfernen können, ohne andere Pakete zu beschädigen. Der einfachste Weg für mich war, das neu hinzugefügte Repository zu deaktivieren, dann werden installierte Pakete von sury.org als selbst erstellte oder veraltete Pakete in aptitude angezeigt und Sie können Paket für Paket herunterstufen.

Bitte beachten Sie, dass PHP-FPM sowohl auf Apache- als auch auf Nginx-Servern verwendet werden kann, während FastCGI nur für Apache-Server verfügbar ist.

2 PHP-Versionen in ISPConfig aktivieren

In ISPConfig 3 können Sie die neuen PHP-Versionen unter System> Zusätzliche PHP-Versionen konfigurieren.

Hinzufügen der PHP-Version von Debian

Sie können diesen Schritt überspringen, wenn Sie keine Debian-Version von PHP installiert haben.

Zunächst müssen Sie eine neue Version für die bereits installierte PHP-Version hinzufügen. Auf der Registerkarte Name geben Sie einfach einen Namen für die PHP-Version ein (z. B. Debian 5.6) - diese PHP-Version wird unter diesem Namen in den Website-Einstellungen in ISPConfig aufgeführt:

Gehen Sie zur Registerkarte FastCGI-Einstellungen und füllen Sie die Felder wie folgt aus:

Path to the PHP FastCGI binary: php5-cgi
Path to the php.ini directory: /etc/php5/cgi/php.ini

Gehen Sie dann auf die Registerkarte PHP-FPM-Einstellungen und füllen Sie die Felder wie folgt aus:

Path to the PHP-FPM init script: php5-fpm
Path to the php.ini directory: /etc/php5/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php5/fpm/pool.d

Wichtiger Schritt für Cronjobs

Wenn Sie Cron-Jobs verwenden, die PHP-Skripte aufrufen, müssen Sie Cron auch mitteilen, welche Version verwendet werden soll. Fügen Sie php5 am Anfang des Befehls hinzu, um die Debian-Version zu verwenden. Wenn Sie sich nicht sicher sind, was Sie genau verwenden, folgen Sie dem symbolischen Link /usr/bin/php und verwenden Sie das endgültige Ziel als Präfix.

Andere PHP-Versionen hinzufügen

Derzeit sind 3 Versionen unter https://packages.sury.org/php/ verfügbar und Sie müssen den letzten Schritt jetzt für jede zu installierende Version wiederholen. Verwenden Sie stattdessen die folgenden Einstellungen:

PHP 5.6

Path to the PHP FastCGI binary: php-cgi5.6
Path to the php.ini directory: /etc/php/5.6/cgi/php.ini
Path to the PHP-FPM init script: php5.6-fpm
Path to the php.ini directory: /etc/php/5.6/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/5.6/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php5.6.

PHP 7.0

Path to the PHP FastCGI binary: php-cgi7.0
Path to the php.ini directory: /etc/php/7.0/cgi/php.ini
Path to the PHP-FPM init script: php7.0-fpm
Path to the php.ini directory: /etc/php/7.0/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.0/fpm/pool.d

Die CLI-Version für z.B. Cron-Jobs hat den Namen php7.0.

PHP 7.1

Path to the PHP FastCGI binary: php-cgi7.1
Path to the php.ini directory: /etc/php/7.1/cgi/php.ini
Path to the PHP-FPM init script: php7.1-fpm
Path to the php.ini directory: /etc/php/7.1/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.1/fpm/pool.d

Die CLI-Version für z.B. Cron-Jobs hat den Namen php7.1.

PHP 7.2

Path to the PHP FastCGI binary: php-cgi7.2
Path to the php.ini directory: /etc/php/7.2/cgi/php.ini
Path to the PHP-FPM init script: php7.2-fpm
Path to the php.ini directory: /etc/php/7.2/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.2/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php7.2.

PHP 7.3

Path to the PHP FastCGI binary: php-cgi7.3
Path to the php.ini directory: /etc/php/7.3/cgi/php.ini
Path to the PHP-FPM init script: php7.3-fpm
Path to the php.ini directory: /etc/php/7.3/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.3/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php7.3.

PHP 7.4

Path to the PHP FastCGI binary: php-cgi7.4
Path to the php.ini directory: /etc/php/7.4/cgi/php.ini
Path to the PHP-FPM init script: php7.4-fpm
Path to the php.ini directory: /etc/php/7.4/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.4/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php7.4.

PHP 8.0

Path to the PHP FastCGI binary: php-cgi8.0
Path to the php.ini directory: /etc/php/8.0/cgi/
Path to the PHP-FPM init script: php8.0-fpm
Path to the php.ini directory: /etc/php/8.0/fpm/
Path to the PHP-FPM pool directory: /etc/php/8.0/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php8.0

PHP 8.1

Path to the PHP FastCGI binary: php-cgi8.1
Path to the php.ini directory: /etc/php/8.1/cgi/
Path to the PHP-FPM init script: php8.1-fpm
Path to the php.ini directory: /etc/php/8.1/fpm/
Path to the PHP-FPM pool directory: /etc/php/8.1/fpm/pool.d

Die CLI-Version für z.B. Cronjobs haben den Namen php8.1

3 PHP-Version von Websites ändern

Sie können diesen Schritt überspringen, wenn Sie keine Debian-Version von PHP installiert haben.

Ändern Sie nun die PHP-Version aller Websites auf die neu erstellte Version (z. B. Debian 5.6).

Und vergessen Sie nicht, die Cronjobs wie oben erwähnt zu ändern.

4 Fügen Sie das Repository unter packages.sury.org hinzu

Verwenden Sie die folgenden Befehle, um das Repository unter packages.sury.org und seine BGP-Schlüssel zu apt hinzuzufügen:

apt-get install -y apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Der nächste Befehl ist nur eine Zeile, fügen Sie keine Zeilenumbrüche hinzu:

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update

Um bereits installierte Pakete aus dem neuen Repository zu aktualisieren, verwenden Sie diesen Befehl:

apt-get upgrade

5 Installieren Sie PHP von packages.sury.org

Ich biete hier mehrere Installationsoptionen an, bitte wählen Sie die gewünschten Versionen aus und überspringen Sie einfach den Rest!

5.1 Installieren Sie PHP 5.6

Um PHP zu installieren, verwenden Sie diesen Befehl:

apt-get install php5.6 php5.6-cli php5.6-cgi php5.6-fpm php5.6-gd php5.6-mysql php5.6-imap php5.6-curl php5.6-intl php5.6-pspell php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip php5.6-mbstring php5.6-soap php5.6-opcache libicu65 php5.6-common php5.6-json php5.6-readline php5.6-xml

5.2 Installieren Sie PHP 7.0

Um PHP zu installieren, verwenden Sie diesen Befehl:

apt-get install php7.0 php7.0-cli php7.0-cgi php7.0-fpm php7.0-gd php7.0-mysql php7.0-imap php7.0-curl php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-zip php7.0-mbstring php7.0-soap php7.0-opcache php7.0-common php7.0-json php7.0-readline php7.0-xml

5.3 Installieren Sie PHP 7.1

Um PHP zu installieren, verwenden Sie diesen Befehl:

apt-get install php7.1 php7.1-cli php7.1-cgi php7.1-fpm php7.1-gd php7.1-mysql php7.1-imap php7.1-curl php7.1-intl php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-zip php7.1-mbstring php7.1-soap php7.1-opcache php7.1-common php7.1-json php7.1-readline php7.1-xml

5.4 Installieren Sie PHP 7.2

Um PHP zu installieren, verwenden Sie diesen Befehl:

apt-get install php7.2 php7.2-cli php7.2-cgi php7.2-fpm php7.2-gd php7.2-mysql php7.2-imap php7.2-curl php7.2-intl php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-zip php7.2-mbstring php7.2-soap php7.2-opcache php7.2-common php7.2-json php7.2-readline php7.2-xml

5.5 Installieren Sie PHP 7.3

Um PHP zu installieren, verwenden Sie diesen Befehl:

apt-get install php7.3 php7.3-cli php7.3-cgi php7.3-fpm php7.3-gd php7.3-mysql php7.3-imap php7.3-curl php7.3-intl php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl php7.3-zip php7.3-mbstring php7.3-soap php7.3-opcache php7.3-common php7.3-json php7.3-readline php7.3-xml

5.6 Installieren PHP 7.4

Um PHP 7.4 zu installieren, verwenden Sie diesen Befehl:

apt-get install php7.4 php7.4-cli php7.4-cgi php7.4-fpm php7.4-gd php7.4-mysql php7.4-imap php7.4-curl php7.4-intl php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-zip php7.4-mbstring php7.4-soap php7.4-opcache libonig5 php7.4-common php7.4-json php7.4-readline php7.4-xml

5.6 Installieren PHP 8.0

Um PHP 8.0 zu installieren, verwenden Sie diesen Befehl:

apt-get install php8.0 php8.0-cli php8.0-cgi php8.0-fpm php8.0-gd php8.0-mysql php8.0-imap php8.0-curl php8.0-intl php8.0-pspell php8.0-sqlite3 php8.0-tidy php8.0-xsl php8.0-zip php8.0-mbstring php8.0-soap php8.0-opcache libonig5 php8.0-common php8.0-readline php8.0-xml

5.6 Installieren PHP 8.1

Um PHP 8.1 zu installieren, verwenden Sie diesen Befehl:

apt-get install php8.1 php8.1-cli php8.1-cgi php8.1-fpm php8.1-gd php8.1-mysql php8.1-imap php8.1-curl php8.1-intl php8.1-pspell php8.1-sqlite3 php8.1-tidy php8.1-xsl php8.1-zip php8.1-mbstring php8.1-soap php8.1-opcache libonig5 php8.1-common php8.1-readline php8.1-xml

6 Memcache-Erweiterung installieren (optional)

Um Memcache zu installieren, verwenden Sie diesen Befehl:

apt-get install php-memcache php-memcached

7 Installieren Sie die APCu-Erweiterung (optional)

Um den APC-Benutzercache zu installieren, verwenden Sie diesen Befehl:

apt-get install php-apcu php-apcu-bc

8 xDebug-Erweiterung installieren (optional)

Das xDebug-Modul ist eine Debugging-Erweiterung für PHP. Die Installation ist optional.

Um xDebug zu installieren, verwenden Sie diesen Befehl:

apt-get install php-xdebug

Dieses Paket scheint andere Standardeinstellungen zu haben als das Debian-Paket php5-xdebug. Abhängig von Ihrer Software müssen Sie Einstellungen wie xdebug.max_nesting_level ändern, um es zum Laufen zu bringen!

9 Setzen Debian-Standard-PHP auf die ursprüngliche Version zurück

Das Standard-PHP des Betriebssystems muss in der ursprünglichen Version bleiben. Um das zu beheben, führen Sie diese Befehle aus:

update-alternatives --config php
update-alternatives --config php-cgi

Wählen Sie bei Debian 11 7.4, bei Debian 10 7.3, bei Debian 9:Wählen Sie PHP 7.0, bei Debian 8 wählen Sie PHP 5.6 im erscheinenden Dialog.

10 Starten Sie den FPM-Daemon neu

Starten Sie abschließend die php-fpm-Daemons neu. Führen Sie die Befehle für die zuvor installierten aus:

service php5.6-fpm restart
service php7.0-fpm restart
service php7.1-fpm restart
service php7.2-fpm restart
service php7.3-fpm restart
service php7.4-fpm restart
service php8.0-fpm restart
service php8.1-fpm restart
  • PHP:http://www.php.net/
  • ISPConfig:http://www.ispconfig.org/
  • Debian:http://www.debian.org/
  • DEB.SURY.ORG:http://deb.sury.org/

Debian
  1. So installieren und verwenden Sie PHP Composer unter Debian 10

  2. So installieren und verwenden Sie PHP Composer unter Debian 9

  3. So bauen Sie PHP 5.6 (PHP-FPM &FastCGI) mit Zend OPcache und APCu für ISPConfig 3 auf Debian 7 (Wheezy)

  4. So installieren Sie PHP 7 (PHP-FPM &FastCGI) für ISPConfig 3 auf Debian 8 (Jessie)

  5. Installieren und konfigurieren Sie Apache und PHP mit mod fastcgi auf Ubuntu/Debian

So installieren Sie Apache mit PHP-FPM unter Debian 10

So installieren Sie Nginx mit PHP-FPM unter Debian 10

So installieren Sie Nginx und PHP unter Debian 10

So installieren Sie Nginx mit PHP-FPM unter Debian 11

So erstellen Sie PHP 5.5 (PHP-FPM &FastCGI) mit ionCube Loader, Zend OPcache und APCu für ISPConfig 3 (Debian Wheezy)

Verwendung mehrerer PHP-Versionen (PHP-FPM &FastCGI) mit ISPConfig 3 (Debian Wheezy)