Để cài đặt PHP 8.3 trên Ubuntu 22.04, chúng ta cần thêm kho lưu trữ ppa:ondrej/php chứa các gói PHP 8.3 cần thiết.
Điều kiện cần thiết:
Hệ thống cài đặt và chạy Ubuntu 22.04.
Quyền truy cập root vào hệ thống.
Để đảm bảo hệ thống được cập nhật:
apt update
Cài đặt bất kỳ bản cập nhật nào có sẵn nếu có và sau đó khởi động lại:
apt upgrade -y
Thêm PHP PPA Repository:
apt -y install software-properties-common
add-apt-repository ppa:ondrej/php
root@vps:~# apt install php8.3 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
amd64-microcode eatmydata intel-microcode iucode-tool libdbus-glib-1-2
libeatmydata1 libevdev2 libimobiledevice6 libplist3 libupower-glib3
libusbmuxd6 python3-importlib-metadata python3-jinja2 python3-json-pointer
python3-jsonpatch python3-jsonschema python3-markupsafe
python3-more-itertools python3-pyrsistent python3-zipp thermald upower
usbmuxd
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.3 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
php-common php8.3-cli php8.3-common php8.3-opcache php8.3-readline ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
php-pear openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.3 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
php-common php8.3 php8.3-cli php8.3-common php8.3-opcache php8.3-readline
ssl-cert
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,506 kB/6,394 kB of archives.
After this operation, 30.5 MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.3-common amd64 8.3.0-1+ubuntu20.04.1+deb.sury.org+1 [704 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.3-opcache amd64 8.3.0-1+ubuntu20.04.1+deb.sury.org+1 [338 kB]
Install PHP 8.3
Đảm bảo gói bổ sung được cập nhật,
apt update
Nếu có bất kỳ bản cập nhật nào, bạn hãy cập nhật hệ thống và khởi động lại:
apt upgrade -y && reboot
Cài đặt PHP 8.3 trên Ubuntu 22.04:
apt install php8.3 -y
Để kiểm tra Phiên bản PHP:
php -v
root@vps:~# php -v
PHP 8.3.0 (cli) (built: Nov 24 2023 08:49:45) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies
Để cài đặt thêm tiện ích mở rộng php
apt install php8.3-<extension>
Để liệt kê các mô-đun/phần mở rộng PHP đã cài đặt,
php -m
Như vậy là bạn đã cài đặt thành công PHP 8.3 trên hệ thống Ubuntu 22.04.