Nah ali ini saya akan berbagi tentang langkah-langkah Konfigurasi VirtualHost atau sering disebut SubDomain pada Debian 8.6 Jessie.
PENGERTIAN
SubDomain Atau sering disebut VirtualHost adalah cara untuk mengatur banyak URL di dalam satu IP.
Maksudnya adalah anda bisa masuk pada suatu IP tanpa menuliskan IP nya,
anda hanya perlu menuliskan SubDomain IP tersebut yang telah di
tambahkan dan anda bisa menambahkan lebih dari satu SubDomain sehingga
dapat menghemat IP.
Contoh SubDomain : mail.yahoo.com, mail.google.com.
Contoh SubDomain : mail.yahoo.com, mail.google.com.
LATAR BELAKANG
Selain domain utama, misal david.net, kita masih bisa untuk menambahkan
SubDomain lagi dari Domain utama tsb. Sehingga kita dapat lebih
menghemat IP Address dan juga domain.
MAKSUD DAN TUJUAN
Untuk mengatur banyak URL dialam satu IP Address. Maksudnya anda bisa
masuk ke suatu IP tanpa menulis IP nya, anda cukup menuliskan SubDomain
IP tsb yang telah ditambahkan dan dapat menambahkan lebih dari satu
SubDomain sehingga mampu menghemat IP.
ALAT DAN BAHAN
- PC (teinstall debian)
- Laptop
- Web Browser
- Koneksi Internet untuk repository
* langkah pertama, server saya remote melalui terminal menggunakan ssh.
* masuk sebagai SuperUser (SU).
* Masuk ke directory /var/www/ dan buatlah sebuah direktori bernama Portal dan file index.html untuk mengisi konten dari subdomain
cd /var/www/
mkdir /var/www/portal -> lokasi website subdomain portal
* kemudian buat file index.html untuk subdomain portal
nano /var/www/portal/index.html
* isikan pada index.html kurang lebih seperti ini
* masuk ke direktori VirtualHost (sites-available)
cd /etc/apache2/sites-available
* copy file default untuk VirtualHost menjadi subportal.conf
cp 000-default.conf portal.conf
* kemudian edit file portal.conf
nano portal.conf
* edit seperti dibawah ini
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin@smekta.net
ServerName smekta.net
ServerAlias portal.smekta.net
DocumentRoot /var/www/portal
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin admin@smekta.net
ServerName smekta.net
ServerAlias portal.smekta.net
DocumentRoot /var/www/portal
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Keterangan :
- ServerAdmin = Alamat email pemilik domain.
- ServerName = Nama domain
- ServerAlias = Nama subdomain yang ingin dialihkan/dijadikan virtual alias.
- DocumentRoot = Tempat pengalihan direktori dari Virtual Alias yang dibuat.
* ketikkan perintah berikut untuk aktifkan Sites/situs
a2ensite subportal.conf
* reload apache2
service apache2 reload
* lalu periksa apakah subdomain telah terkonfigurasi atau belum dengan mengetikkan portal.smekta.net
HASIL
Konfigurasi VirtualHost Pada debian 8.6 Jessie telah selesai
Referensi
Buku konfigurasi Debian Server
Sekian tentang konfigurasi Virtualhost pada debian 8.6 jessie, semoga bermanfaat :-)
0 komentar:
Posting Komentar