Tutorial Linux

Konfigurasi Apache2
di Debian

Panduan dasar untuk memasang Apache2, menyiapkan direktori web, membuat virtual host, dan menguji web server di Debian 12 maupun Debian 13.

Langkah konfigurasi

Setup Apache2 server

Web Server

Konfigurasi Apache2 di Debian

Lihat catatan

Tutorial ini membahas instalasi Apache2, pengecekan service, pembuatan document root, konfigurasi virtual host, dan pengujian hasil.

1
Pasang Apache2

Instal paket web server dari repository Debian.

sudo apt update
sudo apt install apache2 -y
2
Cek status layanan

Pastikan service Apache aktif dan otomatis berjalan saat boot.

sudo systemctl enable apache2
sudo systemctl restart apache2
sudo systemctl status apache2
3
Buat document root website

Siapkan direktori untuk menyimpan file web yang akan ditampilkan.

sudo mkdir -p /var/www/web-sekolah/public_html
sudo chown -R $USER:$USER /var/www/web-sekolah/public_html
4
Buat file index sederhana

Gunakan halaman HTML dasar untuk menguji virtual host.

nano /var/www/web-sekolah/public_html/index.html
5
Buat konfigurasi virtual host

Simpan konfigurasi site baru pada direktori Apache.

sudo nano /etc/apache2/sites-available/web-sekolah.conf

<VirtualHost *:80>
    ServerName web-sekolah.local
    ServerAdmin admin@web-sekolah.local
    DocumentRoot /var/www/web-sekolah/public_html

    ErrorLog ${APACHE_LOG_DIR}/web-sekolah-error.log
    CustomLog ${APACHE_LOG_DIR}/web-sekolah-access.log combined
</VirtualHost>
6
Aktifkan site dan uji konfigurasi

Jalankan validasi sebelum me-restart layanan Apache.

sudo a2ensite web-sekolah.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
7
Uji dari browser atau terminal

Akses IP server atau nama host yang sudah diarahkan ke server.

curl http://localhost
curl http://ip-server
Catatan: jika menggunakan nama domain lokal seperti web-sekolah.local, tambahkan mapping pada file /etc/hosts di komputer client atau gunakan DNS lokal agar domain dapat dikenali.