Skip to main content

[Thủ Thuật Linux] Nâng cấp PHP 8 trên CentOS 7

Nâng cấp PHP 8 trên CentOS 7 là hướng dẫn nâng cấp PHP trên CentOS một cách đơn giản và nhanh chóng. Hãy làm theo các bước dưới đây để nâng cấp nhanh phiên bản PHP của bạn nhé.

Bước 1 - Kết nối với server CentOS 7 bằng ssh

Bước 2 - Disable PHP hiện tại trên CentOS 7

#yum-config-manager --disable remi-php7x

yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php70
yum-config-manager --disable remi-php71
yum-config-manager --disable remi-php72
yum-config-manager --disable remi-php73
yum-config-manager --disable remi-php74

Để kiểm tra phiên bản PHP hiện bạn dùng lệnh  php -v

Bước 3: Tải package PHP theo thứ tự các lệnh như sau

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-8.rpm
rpm -Uvh remi-release-8.rpm epel-release-latest-8.noarch.rpm

Bước 4: Cài đặt PHP 8 trên CentOS 7 và enable PHP theo các lệnh sau

yum install yum-utils

# enable php8
#yum-config-manager --enable remi-php8x
yum-config-manager --enable remi-php81

yum update -y

Bước 5: Kiểm tra bằng lệnh php -v