Konfigurasi Apache2 di Debian
Tutorial ini membahas instalasi Apache2, pengecekan service, pembuatan document root, konfigurasi virtual host, dan pengujian hasil.
Instal paket web server dari repository Debian.
sudo apt update
sudo apt install apache2 -y
Pastikan service Apache aktif dan otomatis berjalan saat boot.
sudo systemctl enable apache2
sudo systemctl restart apache2
sudo systemctl status apache2
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
Gunakan halaman HTML dasar untuk menguji virtual host.
nano /var/www/web-sekolah/public_html/index.html
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>
Jalankan validasi sebelum me-restart layanan Apache.
sudo a2ensite web-sekolah.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
Akses IP server atau nama host yang sudah diarahkan ke server.
curl http://localhost
curl http://ip-server