Lompat ke isi

Share Hosting Server

Dari Wiki Tamansiswa
Revisi sejak 11 Februari 2026 21.59 oleh Admin (bicara | kontrib)

Materi Praktik sebelum share hosting

  1. https://gemini.google.com/share/a767e9163214

Share Hosting Server

Share Hosting memungkinkan satu server melayani beberapa domain berbeda dengan direktori kerja web yang terpisah. Pada modul ini, kita akan mempelajari konsep dan praktik konfigurasi share hosting server.

Tujuan Pembelajaran

Setelah mempelajari modul ini, peserta didik mampu:

  1. Memahami konsep share hosting
  2. Mengkonfigurasi multiple domain dalam satu server
  3. Membuat virtual host Apache
  4. Menguji hasil konfigurasi share hosting

Konsep Share Hosting

Hosting adalah istilah untuk penempatan file atau data pada server. Hosting identik dengan penyewaan space atau ruang kapasitas harddisk server untuk menyimpan data web.

Prinsip Kerja Share Hosting

                    SATU SERVER
    ┌──────────────────────────────────────────┐
    │           IP: 192.168.56.20              │
    │                                          │
    │  ┌─────────────┐  ┌─────────────┐       │
    │  │ Domain A    │  │ Domain B    │       │
    │  │ sekolah.com │  │ toko.com    │       │
    │  │             │  │             │       │
    │  │ /var/www/   │  │ /var/www/   │       │
    │  │ sekolah/    │  │ toko/       │       │
    │  └─────────────┘  └─────────────┘       │
    │                                          │
    │  ┌─────────────┐                        │
    │  │ Domain C    │                        │
    │  │ blog.com    │                        │
    │  │             │                        │
    │  │ /var/www/   │                        │
    │  │ blog/       │                        │
    │  └─────────────┘                        │
    └──────────────────────────────────────────┘

Kekurangan Share Hosting

Templat:Penting

Persiapan Praktik

Ketentuan Konfigurasi

PC Client:

  • IP Address: 192.168.56.1/24
  • OS: Windows 10/11

PC Server (Virtual Machine):

  • IP Address: 192.168.56.20/24
  • OS: Linux Debian 10/11
  • Hostname: linux-server

Domain yang akan dibuat:

Domain IP Address Direktori
panelku.com 192.168.56.20 /var/www/panelku
cobabelajar.net 192.168.56.22 /var/www/belajar
latihan-server.com 192.168.56.23 /var/www/latihan

Langkah Konfigurasi

Langkah 1: Instalasi Paket yang Dibutuhkan

# Login sebagai root
su -

# Update repository
apt update

# Install Apache2
apt install apache2 -y

# Install BIND9 (DNS Server)
apt install bind9 bind9utils dnsutils -y

# Install text editor (opsional)
apt install nano mc -y

Langkah 2: Konfigurasi IP Alias

IP Alias memungkinkan satu interface ethernet memiliki beberapa IP address.

# Edit file interfaces
nano /etc/network/interfaces

Tambahkan konfigurasi berikut:

# Interface utama
auto ens33
iface ens33 inet static
    address 192.168.56.20
    netmask 255.255.255.0
    gateway 192.168.56.1

# IP Alias 1
auto ens33:1
iface ens33:1 inet static
    address 192.168.56.22
    netmask 255.255.255.0

# IP Alias 2
auto ens33:2
iface ens33:2 inet static
    address 192.168.56.23
    netmask 255.255.255.0
# Restart networking
systemctl restart networking

# Verifikasi IP address
ip a

Langkah 3: Membuat Direktori Website

# Buat direktori untuk setiap domain
mkdir -p /var/www/panelku
mkdir -p /var/www/belajar
mkdir -p /var/www/latihan

# Buat file index.html untuk setiap domain
echo "<h1>Selamat Datang di Panelku.com</h1>" > /var/www/panelku/index.html
echo "<h1>Selamat Datang di Cobabelajar.net</h1>" > /var/www/belajar/index.html
echo "<h1>Selamat Datang di Latihan-server.com</h1>" > /var/www/latihan/index.html

# Set permission
chown -R www-data:www-data /var/www/
chmod -R 755 /var/www/

Langkah 4: Konfigurasi Virtual Host Apache

# Masuk ke direktori sites-available
cd /etc/apache2/sites-available

# Salin template default
cp 000-default.conf panelku.conf
cp 000-default.conf belajar.conf
cp 000-default.conf latihan.conf

Edit file panelku.conf:

nano panelku.conf
<VirtualHost 192.168.56.20:80>
    ServerAdmin [email protected]
    ServerName panelku.com
    ServerAlias www.panelku.com
    DocumentRoot /var/www/panelku
    
    <Directory /var/www/panelku>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/panelku_error.log
    CustomLog ${APACHE_LOG_DIR}/panelku_access.log combined
</VirtualHost>

Edit file belajar.conf:

<VirtualHost 192.168.56.22:80>
    ServerAdmin [email protected]
    ServerName cobabelajar.net
    ServerAlias www.cobabelajar.net
    DocumentRoot /var/www/belajar
    
    <Directory /var/www/belajar>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/belajar_error.log
    CustomLog ${APACHE_LOG_DIR}/belajar_access.log combined
</VirtualHost>

Edit file latihan.conf:

<VirtualHost 192.168.56.23:80>
    ServerAdmin [email protected]
    ServerName latihan-server.com
    ServerAlias www.latihan-server.com
    DocumentRoot /var/www/latihan
    
    <Directory /var/www/latihan>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/latihan_error.log
    CustomLog ${APACHE_LOG_DIR}/latihan_access.log combined
</VirtualHost>

Langkah 5: Aktifkan Virtual Host

# Aktifkan setiap site
a2ensite panelku.conf
a2ensite belajar.conf
a2ensite latihan.conf

# Reload Apache
systemctl reload apache2

# Verifikasi status
systemctl status apache2

Langkah 6: Konfigurasi Hosts (Sementara)

Untuk testing tanpa DNS, edit file hosts di client Windows:

# Buka Notepad as Administrator
# Edit file: C:\Windows\System32\drivers\etc\hosts

# Tambahkan baris berikut:
192.168.56.20    panelku.com www.panelku.com
192.168.56.22    cobabelajar.net www.cobabelajar.net
192.168.56.23    latihan-server.com www.latihan-server.com

Pengujian

Test dari Browser

Buka browser dan akses:

  1. http://panelku.com
  2. http://cobabelajar.net
  3. http://latihan-server.com

Hasil yang diharapkan: Setiap domain menampilkan halaman yang berbeda.

Test dengan Curl

# Dari server Linux
curl http://panelku.com
curl http://cobabelajar.net
curl http://latihan-server.com

Troubleshooting

Masalah Solusi
Website tidak tampil Cek status Apache: systemctl status apache2
DNS tidak resolve Cek file /etc/hosts atau konfigurasi BIND
Permission denied Cek ownership: chown -R www-data:www-data /var/www/
Virtual host tidak aktif Jalankan: a2ensite namasite.conf && systemctl reload apache2

Aktivitas Praktik

Tugas Mandiri

Buat konfigurasi share hosting dengan ketentuan:

No Domain Direktori Konten
1 sekolahku.sch.id /var/www/sekolah Profil sekolah
2 perpustakaan.sekolahku.sch.id /var/www/perpus Katalog buku
3 ekskul.sekolahku.sch.id /var/www/ekskul Daftar ekstrakurikuler

Rangkuman

Templat:Rangkuman

Referensi Sub Halaman