Instalasi dan Konfigurasi Web Server Apache2 pada linux debian

 Menginstal server web adalah salah satu konfigurasi paling umum. Debian menggunakan paket apache2 yang mudah dipasang.


Tujuan: Menyediakan konten web melalui protokol HTTP/HTTPS.


Contoh Konfigurasi:


Instalasi Apache2:


Bash


sudo apt update

sudo apt install apache2 -y

Verifikasi Status Layanan:


Bash


sudo systemctl status apache2

Status harus menunjukkan active (running).


Mengaktifkan Virtual Host (untuk hosting banyak situs):


Buat file konfigurasi baru di /etc/apache2/sites-available/:


Bash


sudo nano /etc/apache2/sites-available/contohku.conf

Isi file dengan konfigurasi dasar:


Plaintext


<VirtualHost *:80>

    ServerAdmin webmaster@localhost

    ServerName contohku.local

    DocumentRoot /var/www/html/contohku

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Aktifkan Virtual Host dan restart Apache:


Bash


sudo a2ensite contohku.conf

sudo systemctl restart apache2


Komentar

Postingan Populer