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
Setup Virtual Host Apache di Centos 6
apache
,
centos
,
virtual host
Edit
5 comments:
kalau mau buat virtual host apakah harus membuat dns dulu ya
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.
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
makasih
sangat membantu saya..
ST3 Telkom
Post a Comment