Di CentOS 7 versi PHP yang tersedia di repository default adalah PHP 5.4. Untuk instalasi PHP 7 kita harus menambahkan repository lainnya. Package PHP 7 tersedia di repository Webtatic, IUS, atau Remi. Pada tutorial ini digunakan repository Remi.
Perintah yum info php. Terlihat version PHP 5.4.16.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@lab-centos ~]# yum list php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repo.us.bigstepcloud.com * epel: mirror.steadfast.net * extras: mirrors.gigenet.com * updates: mirrors.gigenet.com Available Packages Name : php Arch : x86_64 Version : 5.4.16 Release : 43.el7_4 Size : 1.4 M Repo : updates/7/x86_64 …
Install apache
[INPUT]1 # yum install httpd
Jalankan service apache
[INPUT]1 2 # systemctl start httpd # systemctl enable httpd
Jika repository EPEL belum tersedia install terlebih dahulu
[INPUT]1 # rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install repository Remi. Repository Remi ini menyediakan PHP versi 5.4, 7.0, 7.1, dan 7.2. Perintah install repository di bawah ini akan menambah file *.repo* di */etc/yum.repos.d*.
[INPUT]1 # rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Lihat isi folder */etc/yum.repos.d*
[INPUT]1 2 3 4 5 6 7 8 # ls -l /etc/yum.repos.d … -rw-r–r–. 1 root root 457 Jun 30 2017 remi-php54.repo -rw-r–r–. 1 root root 1316 Jun 30 2017 remi-php70.repo -rw-r–r–. 1 root root 1316 Jun 30 2017 remi-php71.repo -rw-r–r–. 1 root root 1316 Jun 30 2017 remi-php72.repo -rw-r–r–. 1 root root 2609 Jun 30 2017 remi.repo -rw-r–r–. 1 root root 751 Jun 30 2017 remi-safe.repo
Install paket yum-utils untuk yum-config-manager
[INPUT]1 # yum install yum-utils
Mengaktifkan repository remi-php70
[INPUT]1 # yum-config-manager –enable remi-php70
Cek ulang informasi paket PHP. Apakah sudah mengarah ke repository Remi dengan PHP 7.0.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # yum info php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repo.us.bigstepcloud.com * epel: mirror.steadfast.net * extras: mirrors.gigenet.com * remi-php70: repo1.dal.innoscale.net * remi-safe: repo1.dal.innoscale.net * updates: mirrors.gigenet.com Available Packages Name : php Arch : x86_64 Version : 7.0.26 Release : 1.el7.remi Size : 2.6 M Repo : remi-php70 …
Install PHP
[INPUT]1 # yum install php php-common
Restart service apache agar dapat membaca PHP
[INPUT]1 # systemctl restart httpd
Buat file info.php untuk menguji instalasi PHP
[INPUT]1 # nano /var/www/html/info.php
Isinya
[INPUT]1
Akses *http://localhost/info.php* atau *http://IP_SERVER/info.php*
selamat mencoba ð