Cách cài đặt PHP 5.6 và 7.0 - 8.4 với chế độ PHP-FPM và FastCGI cho ISPConfig 3.2 với apt trên Debian 11 đến 12

theanh

Administrator
Nhân viên
Khi sử dụng ISPConfig, theo mặc định, bạn chỉ có phiên bản PHP chính cho bản phân phối của mình. Hướng dẫn này sẽ hướng dẫn bạn cài đặt các phiên bản PHP bổ sung (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.1, 8.2, 8.3 và 8.4) trên máy chủ Debian với ISPConfig. Một hướng dẫn tương tự có sẵn cho các hệ thống Ubuntu, có thể được tìm thấy tại đây.

Sau khi cài đặt các phiên bản bổ sung, bạn có thể chọn chúng để sử dụng trên các trang web cụ thể ở cả chế độ PHP-FPM và FastCGI.

1 Lưu ý sơ bộ​

Trong hướng dẫn này, bạn sẽ thêm kho lưu trữ SURY bổ sung để cài đặt các gói PHP từ đó với apt. Vì các gói khác như OpenSSL cũng được cập nhật, nên các gói đã cài đặt từ sury.org không thể dễ dàng xóa sau khi cài đặt. Vì vậy, đừng xóa SURY khỏi nguồn kho lưu trữ sau này.

Xin lưu ý rằng PHP-FPM có thể được sử dụng trên máy chủ Apache và Nginx, trong khi FastCGI chỉ khả dụng cho máy chủ Apache.

2 Thêm kho lưu trữ SURY​

Trước tiên, hãy cài đặt các yêu cầu này gói:
Mã:
apt-get install -y apt-transport-https lsb-release ca-certificates
Bây giờ hãy thêm khóa kho lưu trữ bằng cách chạy lệnh này:
Mã:
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg >/dev/null 2>&1
và kho lưu trữ chính nó:
Mã:
echo "deb https://packages.sury.org/php/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/php.list
Bây giờ hãy cập nhật danh sách gói:
Mã:
apt-get update
Để nâng cấp các gói đã cài đặt từ kho lưu trữ mới, hãy sử dụng lệnh:
Mã:
apt-get upgrade

3 Cài đặt các phiên bản PHP bổ sung​

Bạn không cần phải cài đặt mọi phiên bản được liệt kê ở đây, hãy cài đặt những phiên bản bạn cần.

3.1 Cài đặt PHP 5.6​

Để cài đặt PHP, hãy sử dụng lệnh này:
Mã:
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-opcachelibicu65 php5.6-common php5.6-json php5.6-readline php5.6-xml

3.2 Cài đặt PHP 7.0​

Để cài đặt PHP, hãy sử dụng lệnh này:
Mã:
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-opcachephp7.0-common php7.0-json php7.0-readline php7.0-xml

3.3 Cài đặt PHP 7.1​

Để cài đặt PHP, hãy sử dụng lệnh này:
Mã:
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-opcachephp7.1-common php7.1-json php7.1-readline php7.1-xml

3.4 Cài đặt PHP 7.2​

Để cài đặt PHP, hãy sử dụng lệnh này:
Mã:
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-opcachephp7.2-common php7.2-json php7.2-readline php7.2-xml

3.5 Cài đặt PHP 7.3​

Để cài đặt PHP, hãy sử dụng lệnh này:
Mã:
apt-get install php7.3 php7.3-cli php7.3-cgi php7.3-fpmphp7.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-opcachephp7.3-common php7.3-json php7.3-readline php7.3-xml

3.6 Cài đặt PHP 7.4​

Để cài đặt PHP 7.4, hãy sử dụng lệnh này:
Mã:
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-opcachelibonig5 php7.4-common php7.4-json php7.4-readline php7.4-xml

3.7 Cài đặt PHP 8.0​

Để cài đặt PHP 8.0, hãy sử dụng lệnh này:
Mã:
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

3.8 Cài đặt PHP 8.1​

Để cài đặt PHP 8.1, hãy sử dụng lệnh này:
Mã:
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

3.9 Cài đặt PHP 8.2​

Để cài đặt PHP 8.2, hãy sử dụng lệnh này lệnh:
Mã:
apt-get install php8.2 php8.2-cli php8.2-cgi php8.2-fpm php8.2-gd php8.2-mysql php8.2-imap php8.2-curl php8.2-intl php8.2-pspell php8.2-sqlite3 php8.2-tidy php8.2-xsl php8.2-zip php8.2-mbstring php8.2-soap php8.2-opcache libonig5 php8.2-common php8.2-readline php8.2-xml

3.10 Cài đặt PHP 8.3​

Để cài đặt PHP 8.3, hãy sử dụng lệnh này:
Mã:
apt-get install php8.3 php8.3-cli php8.3-cgi php8.3-fpm php8.3-gd php8.3-mysql php8.3-imap php8.3-curl php8.3-intl php8.3-pspell php8.3-sqlite3 php8.3-tidy php8.3-xsl php8.3-zip php8.3-mbstring php8.3-soap php8.3-opcache libonig5 php8.3-common php8.3-readline php8.3-xml

3.11 Cài đặt PHP 8.4​

Để cài đặt PHP 8.4, hãy sử dụng lệnh này lệnh:
Mã:
apt-get install php8.4 php8.4-cli php8.4-cgi php8.4-fpm php8.4-gd php8.4-mysql php8.4-imap php8.4-curl php8.4-intl php8.4-pspell php8.4-sqlite3 php8.4-tidy php8.4-xsl php8.4-zip php8.4-mbstring php8.4-soap php8.4-opcache libonig5 php8.4-common php8.4-readline php8.4-xml

4 Đặt lại PHP mặc định của hệ điều hành về phiên bản chính xác​

PHP mặc định của hệ điều hành phải giữ nguyên phiên bản gốc. Để khắc phục điều đó, hãy chạy từng lệnh sau:
Mã:
update-alternatives --config php
update-alternatives --config php-cgi
update-alternatives --config php-fpm.sock
Trên Debian 12, chọn 8.2; trên Debian 11, chọn 7.4; trên Debian 10, chọn 7.3.

5 Thêm phiên bản PHP vào ISPConfig​

Trong ISPConfig 3, bạn có thể cấu hình các phiên bản PHP mới trong System > Additional PHP Versions > Thêm phiên bản PHP mới.

Thêm phiên bản PHP mặc định của bản phân phối​

Đầu tiên, bạn phải thêm phiên bản mới cho phiên bản PHP đã cài đặt. Phiên bản mặc định phụ thuộc vào bản phát hành bạn đang sử dụng:

Debian 10: PHP 7.3
Debian 11: PHP 7.4
Debian 12: PHP 8.2

Xem bên dưới để biết cấu hình cho phiên bản của bạn.

Cấu hình cho các phiên bản PHP bổ sung​

PHP 5.6​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi5.6
[B]Path to the php.ini directory:[/b] /etc/php/5.6/cgi/
PHP-FPM cài đặt:
Mã:
[B]Path to the PHP-FPM init script:[/b]php5.6-fpm
[B]Path to the php.ini directory:[/b] /etc/php/5.6/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/5.6/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php5.6
PHP 7.0​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi7.0
[B]Path to the php.ini directory:[/b] /etc/php/7.0/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b]php7.0-fpm
[B]Path to the php.ini directory:[/b] /etc/php/7.0/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/7.0/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php7.0
PHP 7.1​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi7.1
[B]Path to the php.ini directory:[/b] /etc/php/7.1/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php7.1-fpm
[B]Path to the php.ini directory:[/b] /etc/php/7.1/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/7.1/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php7.1
PHP 7.2​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi7.2
[B]Path to the php.ini directory:[/b] /etc/php/7.2/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php7.2-fpm
[B]Path to the php.ini directory:[/b] /etc/php/7.2/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/7.2/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php7.2
PHP 7.3​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi7.3
[B]Path to the php.ini directory:[/b] /etc/php/7.3/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php7.3-fpm
[B]Path to the php.ini directory:[/b] /etc/php/7.3/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/7.3/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php7.3
PHP 7.4​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi7.4
[B]Path to the php.ini directory:[/b] /etc/php/7.4/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php7.4-fpm
[B]Path to the php.ini directory:[/b] /etc/php/7.4/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/7.4/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php7.4
PHP 8.0​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi8.0
[B]Path to the php.ini directory:[/b] /etc/php/8.0/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php8.0-fpm
[B]Path to the php.ini directory:[/b] /etc/php/8.0/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/8.0/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php8.0
PHP 8.1​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi8.1
[B]Path to the php.ini directory:[/b] /etc/php/8.1/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php8.1-fpm
[B]Path to the php.ini directory:[/b] /etc/php/8.1/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/8.1/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php8.1
PHP 8.2​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi8.2
[B]Path to the php.ini directory:[/b] /etc/php/8.2/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php8.2-fpm
[B]Path to the php.ini directory:[/b] /etc/php/8.2/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/8.2/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php8.2
PHP 8.3​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi8.3
[B]Path to the php.ini directory:[/b] /etc/php/8.3/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php8.3-fpm
[B]Path to the php.ini directory:[/b] /etc/php/8.3/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/8.3/fpm/pool.d/
Phiên bản cli cho ví dụ. công việc cron có tên là php8.3
PHP 8.4​
Cài đặt Fast-CGI:
Mã:
[B]Path to the PHP FastCGI binary:[/b] /usr/bin/php-cgi8.4
[B]Path to the php.ini directory:[/b] /etc/php/8.4/cgi/
Cài đặt PHP-FPM:
Mã:
[B]Path to the PHP-FPM init script:[/b] php8.4-fpm
[B]Path to the php.ini directory:[/b] /etc/php/8.4/fpm/
[B]Path to the PHP-FPM pool directory:[/b] /etc/php/8.4/fpm/pool.d/
Phiên bản cli cho ví dụ. cron jobs có tên là php8.4

6 Kết luận​

Bây giờ bạn có thể chọn thêm phiên bản PHP cho trang web của mình. Nếu bạn có bất kỳ câu hỏi nào, hãy mở một chủ đề trong diễn đàn.
 
Back
Bên trên