konfigurasi virtual host:www.hafid.lab/blog.hafid.lab/cms.hafid.lab/lms.hafid.lab

 

1. Buat Folder untuk Masing-Masing Domain

Buat folder root untuk setiap domain di direktori web server (biasanya /var/www/):

pesta
sudo mkdir -p /var/www/www.hafid.lab
sudo mkdir -p /var/www/blog.hafid.lab
sudo mkdir -p /var/www/cms.hafid.lab
sudo mkdir -p /var/www/lms.hafid.lab

2. Buat File Indeks untuk Masing-Masing Situs

Contoh sederhana untuk memastikan situs dapat diakses:

pesta
echo "<h1>Selamat datang di www.hafid.lab</h1>" | sudo tee /var/www/www.hafid.lab/index.html
echo "<h1>Selamat datang di blog.hafid.lab</h1>" | sudo tee /var/www/blog.hafid.lab/index.html
echo "<h1>Selamat datang di cms.hafid.lab</h1>" | sudo tee /var/www/cms.hafid.lab/index.html
echo "<h1>Selamat datang di lms.hafid.lab</h1>" | sudo tee /var/www/lms.hafid.lab/index.html

3. Atur Folder Izin

Berikan izin akses agar Apache dapat membaca folder-folder tersebut:

pesta
sudo chown -R www-data:www-data /var/www/*
sudo chmod -R 755 /var/www/*

4. Membuat File Konfigurasi Virtual Host

Buat file konfigurasi virtual host untuk setiap domain di direktori /etc/apache2/sites-available/:

a. Untukwww.hafid.lab
pesta
sudo nano /etc/apache2/sites-available/www.hafid.lab.conf

Isi file:

apache
<VirtualHost *:80>
ServerName www.hafid.lab
DocumentRoot /var/www/www.hafid.lab

<Directory /var/www/www.hafid.lab>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/www.hafid.lab_error.log
CustomLog ${APACHE_LOG_DIR}/www.hafid.lab_access.log combined
</VirtualHost>
b. Untukblog.hafid.lab
pesta
sudo nano /etc/apache2/sites-available/blog.hafid.lab.conf

Isi file:

apache
<VirtualHost *:80>
ServerName blog.hafid.lab
DocumentRoot /var/www/blog.hafid.lab

<Directory /var/www/blog.hafid.lab>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/blog.hafid.lab_error.log
CustomLog ${APACHE_LOG_DIR}/blog.hafid.lab_access.log combined
</VirtualHost>
c. Untukcms.hafid.lab
pesta
sudo nano /etc/apache2/sites-available/cms.hafid.lab.conf

Isi file:

apache
<VirtualHost *:80>
ServerName cms.hafid.lab
DocumentRoot /var/www/cms.hafid.lab

<Directory /var/www/cms.hafid.lab>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/cms.hafid.lab_error.log
CustomLog ${APACHE_LOG_DIR}/cms.hafid.lab_access.log combined
</VirtualHost>
d. Untuklms.hafid.lab
pesta
sudo nano /etc/apache2/sites-available/lms.hafid.lab.conf

Isi file:

apache
<VirtualHost *:80>
ServerName lms.hafid.lab
DocumentRoot /var/www/lms.hafid.lab

<Directory /var/www/lms.hafid.lab>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/lms.hafid.lab_error.log
CustomLog ${APACHE_LOG_DIR}/lms.hafid.lab_access.log combined
</VirtualHost>

5. Aktifkan Konfigurasi Virtual Host

Aktifkan konfigurasi file masing-masing:

pesta
sudo a2ensite www.hafid.lab.conf
sudo a2ensite blog.hafid.lab.conf
sudo a2ensite cms.hafid.lab.conf
sudo a2ensite lms.hafid.lab.conf

6. Edit File Host Lokal (Opsional - Jika Akses dari Mesin Lokal)

Tambahkan entri domain ke file /etc/hosts(di mesin klien):

pesta
sudo nano /etc/hosts

Tambahkan baris berikut:

127.0.0.1 www.hafid.lab
127.0.0.1 blog.hafid.lab
127.0.0.1 cms.hafid.lab
127.0.0.1 lms.hafid.lab

7. Mulai ulang Apache

Pastikan konfigurasi tidak ada kesalahan, lalu restart Apache:

pesta
sudo apache2ctl configtest
sudo systemctl reload apache2

Pengujian

Buka browser dan akses domain masing-masing:

  • http://www.hafid.lab
  • http://blog.hafid.lab
  • http://cms.hafid.lab
  • http://lms.hafid.lab












Comments

Popular posts from this blog

instal driver windows 11

Membuat kesimpulan Introduction to Networks ( Version 7.00) - ITN Practice PT Skills Assessment (PTSA)

instalasi windows11 , di virtualbox