بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم

Apache itu web server yang populer. Web server itu program yang menampilkan website. Apache dibuat oleh Apache Software Foundation. Tutorial ini menjelaskan cara menyiapkan Apache. Kamu juga bisa menghubungkannya dengan PHP kalau perlu.

Di Arch Linux, MySQL digantikan oleh MariaDB. MariaDB itu pengganti MySQL yang cara pakainya sama. Jadi perintah-perintah di bawah memakai MariaDB, tapi cara kerjanya sama seperti MySQL.

Instalasi

Install dulu paket yang dibutuhkan:

sudo pacman -S php apache mariadb php-apache phpmyadmin

Perintah ini menginstall semuanya sekaligus. mcrypt tidak perlu diinstall. mcrypt sudah dihapus dari PHP sejak versi 7.2, dan phpMyAdmin tidak membutuhkannya.

Konfigurasi

Buka file konfigurasi Apache:

sudo nano /etc/httpd/conf/httpd.conf

Beri tanda pagar di awal baris ini:

LoadModule mpm_event_module modules/mod_mpm_event.so

Lalu hapus tanda pagar di awal baris ini:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Tambahkan tiga baris ini di akhir file, lalu simpan filenya:

LoadModule php_module modules/libphp.so
AddHandler php-script .php
Include conf/extra/php_module.conf

Sebelum restart, cek dulu konfigurasinya:

sudo apachectl configtest

Hasilnya harus Syntax OK. Kalau ada error, baca pesannya dan perbaiki baris yang disebut.

Sekarang jalankan Apache dan cek statusnya:

sudo systemctl enable httpd
sudo systemctl restart httpd
sudo systemctl status httpd

img1

Lalu atur MySQL. MySQL itu database tempat menyimpan data website.

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Jalankan MySQL:

sudo systemctl enable mysqld
sudo systemctl start mysqld
sudo systemctl status mysqld

img2

Kalau MySQL sudah jalan, buat password root. Perintah ini harus dijalankan dengan sudo supaya bisa masuk sebagai root. Tekan Enter saja kalau ada pertanyaan. Contohnya bisa dilihat di gambar bawah ini:

sudo mysql_secure_installation

img3

Sekarang tes PHP. Buat dulu file tes di folder /srv/http/:

sudo nano /srv/http/test.php

Isi filenya dengan ini:

<?php
phpinfo();
?>

img4

Buka alamat ini di browser: http://localhost/test.php

img5

Selanjutnya atur phpMyAdmin. phpMyAdmin itu aplikasi web untuk mengatur database MySQL lewat browser.

sudo nano /etc/php/php.ini

Aktifkan ekstensi berikut. Caranya, hapus titik koma di depannya. Kalau ekstensinya tidak ada di daftar, tambahkan sendiri:

extension=pdo_mysql
extension=mysqli
extension=bz2
extension=zip
extension=iconv.so

Buka file konfigurasi phpMyAdmin:

sudo nano /etc/httpd/conf/extra/phpmyadmin.conf

Isi filenya dengan ini:

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>

img6

Tambahkan baris ini ke file /etc/httpd/conf/httpd.conf, lalu cek konfigurasinya dan restart Apache:

Include conf/extra/phpmyadmin.conf
sudo apachectl configtest
sudo systemctl restart httpd

Buka alamat ini di browser: http://localhost/phpmyadmin/

img7

Semoga bermanfaat.

Referensi

  1. https://wiki.archlinux.org/title/Apache_HTTP_Server
  2. https://wiki.archlinux.org/title/PHP
  3. https://wiki.archlinux.org/title/phpMyAdmin