in FOSS

Cara Install PHP 7.4 di CentOS 8

Cara Install PHP 7.4 di CentOS 8

Secara default PHP yang tersedia di CentOS 8 adalah versi 7.2, sementara Security Support dari PHP 7.2 sebentar lagi akan habis masa dukungannya pada tanggal 30 November 2020. Dalam beberapa kasus juga, aplikasi PHP yang ingin dijalankan di CentOS 8 membutuhkan PHP versi di atasnya atau terbaru.

0.Mengecek Versi PHP

Mengecek versi PHP yang terbaca di cache repository.

dnf info php

Available Packages
Name         : php
Version      : 7.2.24
Release      : 1.module_el8.2.0+313+b04d0a66
Architecture : x86_64
Size         : 1.5 M
Source       : php-7.2.24-1.module_el8.2.0+313+b04d0a66.src.rpm
Repository   : AppStream

1.Install EPEL dan REMI Repository

Install terlebih dahulu EPEL dan REMI repository.

dnf install epel-release -y
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y	

Cek PHP yang tersedia di module.

dnf module list php

CentOS-8 - AppStream
Name           Stream             Profiles                             Summary                         
php            7.2 [d]            common [d], devel, minimal           PHP scripting language          
php            7.3                common [d], devel, minimal           PHP scripting language          

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name           Stream             Profiles                             Summary                         
php            remi-7.2           common [d], devel, minimal           PHP scripting language          
php            remi-7.3           common [d], devel, minimal           PHP scripting language          
php            remi-7.4           common [d], devel, minimal           PHP scripting language          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

2.Aktifkan PHP 7.4 Module Stream

Aktifkan php:remi-7.4 module stream.

dnf module enable php:remi-7.4

Dependencies resolved.
=======================================================================================================
 Package                 Architecture           Version                  Repository               Size
=======================================================================================================
Enabling module streams:
 php                                            remi-7.4                                              

Transaction Summary
=======================================================================================================

Is this ok [y/N]: y

3.Install PHP 7.4

Sekarang install PHP 7.4.

dnf install php php-cli php-common	

Uji hasil instalasi dengan mengecek versi PHP.

php -v

PHP 7.4.7 (cli) (built: Jun  9 2020 10:57:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.7, Copyright (c), by Zend Technologies	

4.PHP dengan Apache

Saat install PHP tadi juga terinstall Apache web server (HTTPD). Aktifkan dan jalankan servicenya.

systemctl enable httpd	
systemctl start httpd	
systemctl status httpd	

Cek juga status php-fpm service, karena di CentOS 8 tidak lagi menggunakan Apache module. Install PHP tadi juga sudah menginstall PHP-FPM.

systemctl enable php-fpm
systemctl status php-fpm	

Membuat file info.php untuk menguji Apache apakah sudah bisa menjalankan PHP script.

cd /var/www/html
echo "" > info.php	

Browse `http://SERVER-IP/info.php`.

PHP Information

PHP Information

Selamat mencoba 🙂

Write a Comment

Comment

  1. Makasih banyak mas, tulisan ini sangat membantu saya setelah seharian gagal upgrade php dari 7.2 ke 7.4 selalu nyangkut di 7.2