Cara Install PHP dengan Apache di CentOS 8
PHP adalah salah satu bahasa pemrograman paling populer di dunia yang digunakan untuk membangun website. PHP menjadi bagian dari LAMP (Linux Apache MariaDB PHP) / LEMP (Linux Nginx MariaDB PHP) stack.
0.Install Apache
Install Apache terlebih dahulu.
1 2 3 | dnf install httpd -y systemctl enable --now httpd systemctl status httpd |
Ijinkan http di firewall.
1 2 3 | firewall-cmd --add-service=http --permanent firewall-cmd --reload firewall-cmd --list-services |
Baca tutorial lengkap Apache di Cara Install Apache di CentOS 8
1.Install PHP
Versi PHP yang tersedia secara default di CentOS 8 adalah PHP versi 7.2.1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | dnf info php Name : php Version : 7.2.11 Release : 1.module_el8.0.0+56+d1ca79aa Arch : x86_64 Size : 4.9 M Source : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm Repo : @System From repo : AppStream Summary : PHP scripting language for creating dynamic web sites URL : http://www.php.net/ License : PHP and Zend and BSD and MIT and ASL 1.0 Description : PHP is an HTML-embedded scripting language. PHP attempts to make it : easy for developers to write dynamically generated web pages. PHP : also offers built-in database integration for several commercial and : non-commercial database management systems, so writing a : database-enabled webpage with PHP is fairly simple. The most common : use of PHP coding is probably as a replacement for CGI scripts. : : The php package contains the module (often referred to as mod_php) : which adds support for the PHP language to Apache HTTP Server. |
Install paket PHP.
1 | dnf install php |
Apache web server di CentOS 8 secara default memakai PHP-FPM, tidak memakai mod_php untuk menjalankan script PHP. Jadi, kita perlu menjalankan dan mengaktifkan php-fpm service.
1 2 3 | systemctl enable php-fpm systemctl start php-fpm systemctl status php-fpm |
2.Pengujian
Mengecek hasil install PHP.
1 2 3 4 5 | php -v PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies |
Mengecek hasil install PHP dengan membuat file PHPInfo.
1 2 | cd /var/www/html echo "<?php phpinfo(); ?>" > info.php |
Lalu browsing http://ip-server/info.php.
3.Mencari Extension PHP
Jika membutuhkan extension atau module PHP yang lain, cari nama paketnya dengan perintah dnf.
1 2 3 4 5 6 7 | dnf search php- php-gd.x86_64 : A module for PHP applications for using the gd graphics library php-cli.x86_64 : Command-line interface for PHP php-fpm.x86_64 : PHP FastCGI Process Manager php-cli.x86_64 : Command-line interface for PHP ... |
Selamat mencoba 🙂
Mas Musa, kalau instal menggunakan command dnf apa pakai repo juga?
yes, dnf ini pengganti dari yum, ngambil paketnya juga dari repository