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.