Cách cài đặt PHP 8.2 trên Ubuntu 22.04

Article ID: 1075
Cập nhật gần nhất: 05 Th09, 2024

PHP là ngôn ngữ kịch bản và trình thông dịch được cung cấp miễn phí và chủ yếu được sử dụng trên máy chủ web Linux.

Để cài đặt PHP 8.2, chúng ta cần thêm/kho lưu trữ PHP PPA chứa các gói PHP 8.2 mà chúng ta cần.

Điều kiện tiên quyết:

Hệ thống cài đặt và chạy Ubuntu 22.04.

quyền truy cập gốc vào hệ thống.


Để đảm bảo hệ thống được cập nhật.

apt update

Nếu có bản cập nhật nào, hãy cập nhật hệ thống và khởi động lại.

apt upgrade -y && reboot

Thêm kho lưu trữ PHP PPA

apt -y install software-properties-common

add-apt-repository ppa:ondrej/php

Output:
 

root@vps:~# add-apt-repository ppa:ondrej/php
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main'
Description:
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

Cài đặt PHP 8.2

Đảm bảo gói bổ sung được cập nhật.

apt update

Nếu có bản cập nhật nào, hãy cập nhật hệ thống và khởi động lại.

apt upgrade -y && reboot

Cài đặt PHP 8 trên Ubuntu

apt install php8.2 -y

Để kiểm tra phiên bản PHP.

root@vps:~# php -v
PHP 8.2.0 (cli) (built: Dec 10 2022 10:53:01) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
  with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

Để cài đặt tiện ích mở rộng php.

apt install php8.2-<extension>

Để liệt kê các module/phần mở rộng php đã cài đặt.

php -m

Như vậy là chúng ta đã kết thúc chủ đề cài đặt PHP 8.2 trên hệ thống Ubuntu 22.04.

Article ID: 1075
Cập nhật gần nhất: 05 Th09, 2024
Lần sửa đổi: 1
Lượt xem: 0