How To Setup Multiple Virtual Hosts In Apache

กรณีต้องการให้เครื่อง localhost เครื่องเดียว เรียกได้หลาย domain ทำได้ดังนี้
1.ตั้งค่า virtualhost ใน apache ที่ไฟล์ /etc/apache2/https.conf
NameVirtualHost 127.0.0.1:80
< VirtualHost 127.0.0.1:80 >
ServerName test.sci.com
DocumentRoot "/var/www/test"
< /VirtualHost >
< VirtualHost 127.0.0.1:80 >
ServerName cc.sci.com
DocumentRoot "/var/www/cc"
< /VirtualHost >



2.แก้ไขไฟล์ /etc/hosts เพื่อให้เรียกใช้ตามชื่อ ที่ ตั้งไว้ในข้อ 1

127.0.0.1 test.sci.com
127.0.0.1 cc.sci.com


นอกจากนี้ก็มีตัวอย่างอีกหลายแบบ ดูได้ที่
http://httpd.apache.org/docs/2.0/vhosts/examples.html

Comments

Popular posts from this blog

Artillery Hornet + OctoPrint + Klipper

ย้ายบ้าน

ใต้ร่มกาสาวพัตร