Setting Virtual Host In XAMPP


I have try a little bit experiment in setting up virtual host in XAMPP. By default, domain name of apache server is localhost. when we using virtual host, we can set up multiple domain name in apache server. Supposed You want to set up http://adisembiring.com, http://sembiringadi.com, http://forum.adisembiring.com and etc.

How to configure apache in xampp in order to have virtual host ability. Check it out😀

  • Open your virtual on http_vhost.conf in your apache extra configuration directory. my file path is: C:\xampp\apache\conf\extra\httpd-vhosts.conf.
  • To set listened port of apache virtual host, uncomment NameVirtualHost and specify the listened port. ex, NameVirtualHost *:80
  • Specify the document root of virtual host and server name
<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot E:/data/httdocs/forum
	ServerName servername.com

	<Directory "E:/data/httdocs/forum">
		Options Indexes FollowSymLinks Includes ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>
  • configure host driver in the C:\WINDOWS\system32\drivers\etc\hosts file
  • add new server host 127.0.0.1        servername.com

this is my virtual host configuration

NameVirtualHost *:80
<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot E:/data/httdocs/forum
	ServerName ravelex.biz

	<Directory "E:/data/httdocs/forum">
		Options Indexes FollowSymLinks Includes ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot E:/data/httdocs
	ServerName localhost

	<Directory "E:/data/httdocs">
		Options Indexes FollowSymLinks Includes ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot E:/data/httdocs/ravelex
	ServerName rportal.biz

	<Directory "E:/data/httdocs/ravelex">
		Options Indexes FollowSymLinks Includes ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>

NB: When you setup virtual host in your xampp server, your localhost will not work anymore. To make it work again, you can add new virtual host redirected to localhost as I have write above.

Hope this article help you. Thanks😀

11 thoughts on “Setting Virtual Host In XAMPP

  1. Rudi Simamora January 18, 2010 / 1:05 pm

    lek, bukan ‘Sepsify’ tapi ‘Specify’ tuh lek!
    but over all, nice info lah!

  2. adisembiring January 18, 2010 / 6:04 pm

    hihihi …, thanks for your review.😀

  3. wong jowo March 23, 2010 / 7:53 am

    CMIIW,

    yg bikin bisa diakses dari browser http://rportal.biz itu setting di C:\Windows\System32\Drivers\etc\hosts nya, bukan gara-gara virtual host apache nya.

    Virtual host apache hanya deteksi, kalau request urlnya http://rportal.biz,dia akan redirect ke local path tertentu.

  4. sunardo panjaitan September 25, 2010 / 12:42 pm

    @Wong jowo…
    file C:\Windows\System32\Drivers\etc\hosts (di windows) atau /etc/hosts (di unix) adalah untuk mapping IP Address ke Domain Name System atau sebaliknya.
    File ini merupakan file yang pertama dibaca oleh komputer (first priority) untuk mapping ip address dan domain, secondly is DNS server.

    Apache/ Web server berfungsi untuk mentransfer halaman web (data dari server/harddisk, dsb) yang diminta oleh client.

    @Ady sedikit info lek…
    Virtual host juga bisa berdasarkan ip address, bukan hanya nama saja.
    Mengenai info yg lebih jelas, googlekan aja lek…
    soalnya kalo dijelaskan, celotehku ini bakalan panjang bngt..:D

  5. banker February 22, 2011 / 3:34 am

    setelah dicoba ternyata service apache nya gak mau jalan tuh kenapa gan??
    salah edit dmn ya??

    • adisembiring February 22, 2011 / 3:38 am

      Wah .. ane kurang tau salah dimane gan. soalnya bukan ane yang configure punya ente heheheh.
      coba configure ulang deh gan, pelan2, perhatikan langkah yang ane buat di postingan.

      Semoga berhasil gan😀

  6. banker February 22, 2011 / 4:34 am

    hmm..tapi apakah cmn kita harus ngedit file host.conf dan httpd-vhost.conf aja gan??..cmn 2 itu?
    gak ada lagi??

    kalo agan dulu nyoba itu gmn lho?

    • adisembiring February 22, 2011 / 4:37 am

      kalau saya dulu ya coba sesuai step diata gan. sudah berjalan dengan baik koq.

  7. schimmel voet March 30, 2013 / 5:13 pm

    If you wish for to increase your experience only keep visiting this site and be updated with the latest information posted here.

  8. bestanden terug halen May 12, 2013 / 10:55 am

    Pretty nice post. I just stumbled upon your
    blog and wanted to say that I’ve truly enjoyed surfing around your blog posts. In any case I will be subscribing to your rss feed and I hope you write again very soon!

  9. casino May 16, 2013 / 3:07 am

    Very good post. I definitely love this site.

    Continue the good work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s