Setup Virtual Host Apache di Centos 6

1. Setup konfigurasi apache
# mkdir /etc/httpd/site
# cd /etc/httpd/conf/httpd.conf
# vi httpd.conf

Tambahkan baris berikut pada akhir konfigurasi:
NameVirtualHost *:80
Include /etc/httpd/site/*

# vi /etc/httpd/site/domain.conf

Isi file domain.conf
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot "/var/www/vhost/domain.com/html"
ErrorLog logs/domain.com-error_log
CustomLog logs/domain.com-access_log common
<Directory "/var/www/vhost/domain.com/html">
         AllowOverride all
</Directory>
</VirtualHost>


2. Buat direktori dan file index untuk domain.com
# mkdir /var/www/vhost/domain.com/
# mkdir /var/www/vhost/domain.com/hmtl
# vi /var/www/vhost/domain.com/index.php

Isi index.php
<?php
echo "domain.com";
?>

3. Restart service apache
# /etc/init.d/httpd restart

4. Testing
Akses melalui browser http://domain.com


Share on Google Plus

About Admin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

5 comments:

AdliLD said...

kalau mau buat virtual host apakah harus membuat dns dulu ya

Admin said...

Reply: AdliLD
Virtual Host dan DNS itu konfigurasi yang berbeda, tapi saling ketergantungan. DNS nanti fungsi nya untuk mengarahkan domain menuju ke server mana. Setelah tujuan server ditemukan, web server akan memfilter ketika ada request dari user, domain apa yang dituju, kemudian mengarahkan ke home direktori domain yang dimaksud.

Unknown said...

Saya tertarik dengan postingan anda ini, informasi setup virtual hostpache yg sangat berguna sekali.
Saya juga mempunyai tulisan yang sejenis yang bisa anda kunjungi di
Informasi Seputar Cisco Gunadarma

marselianadwi said...

makasih

Adel Jopong said...

sangat membantu saya..


ST3 Telkom