Sudah lama saya ingin membuat virtualhost di xampp yang sudah terinstall di komputer saya, akhirnya setelah browsing di mbah google saya menemukan tutorialnya, dan sekarang saya ingin membaginya.
Pengertiannya, Virtualhost adalah : Host buatan atau simulasi host pada server apache atau localhost. Contoh anda harus mengakses website anda dengan http://localhost/tude32.com dengan Virtualhost alamat website anda menjadi http://tude32.com mudah bukan ??
Tentu ini akan memudahkan anda bagi yang mempunyai banyak pekerjaan dalam membuat website, terlebih Webdeveloper.
Baiklah langsung saja bagaimana kita akan membahas Cara membuat Virtualhost pada XAMPP Windows
1.Instal XAMPP
2.Buka file host (C:\WINDOWS\system32\drivers\etc)
Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
3.Lalu tambahkan virtual host IP 127.0.0.1 tude32.com di dalam file tersebut (seperti terlihat dibawah ini)
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
127.0.0.1 tude32.com
Kalian juga bisa menambahkan virtualhost lebih dari satu, ulangi langkah ke tiga jika ingin menambahkan virtualhost lagi.
- Buka file httpd.conf (C:\xampp\apache\conf), lalu setting directory permission supaya bisa diakses oleh siapapun.(lihat bagian bawah ini)
Cari kode dibawah:
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Lalu ganti dengan kode dibawah:
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Save file tersebut.
- Lalu buka lagi file httpd-vhosts.conf (C:\xampp\apache\conf\extra), tambahkan ServerName dan DocumentRoot pada file tersebut. (lihat dibawah)
Cari ##NameVirtualHost, seperti dibawah:
##NameVirtualHost *:80
Hilangkan tanda ## sehingga akan terlihat seperti dibawah ini::
NameVirtualHost *:80
Tambahkan virtualhost Anda yang terdiri dari ServerName dan DocumentRoot.
#VirtualHost Anda
DocumentRoot C:/xampp/htdocs/belajar-web.com
ServerName belajar-web.com
#Untuk membedakan localhost dengan virtualHost Anda:
DocumentRoot C:/xampp/htdocs
ServerName localhost
Jangan lupa untuk save
- Langkah terakhir yaitu, membuat folder dengan nama file tude32.com di C:\xampp\htdocs