Config apache ให้มีได้หลายโดเมน บน localhost

เริ่มโดย awat, 18 กรกฎาคม 2009, 12:15:31

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

awat

เอามาฝากกัน พอดีผมทดสอบ โปรแกรมแล้วอยากได้ subdomain บน localhost และอยากได้หลาย ๆ โดเมน

เป็น apache web server นะครับ

ง่าย ๆ จะมีการแก้ไขไฟล์ 2 ไฟล์ด้วยกันครับ

1. \Apache\Apache2.2\conf\httpd.txt
2. C:\WINDOWS\System32\drivers\etc\host

ขั้นตอนการแก้ไข

ตัวอย่าง
site1.local  ที่มี root อยู่ที่ D:\webserver\www\site1
site2.local  ที่มี root อยู่ที่ D:\webserver\www\site2


1. \Apache\Apache2.2\conf\httpd.txt
แก้ไข โดยเพิ่ม

อ้างถึง
NameVirtualHost 127.0.0.1


<VirtualHost 127.0.0.1>
   DocumentRoot "D:\webserver\www\site1"
   ServerName site1.local
</VirtualHost>

<VirtualHost 127.0.0.1>
   DocumentRoot "D:\webserver\www\site2"
   ServerName site2.local
</VirtualHost>

2. C:\WINDOWS\System32\drivers\etc\host
แก้ไขโดยเพิ่ม

อ้างถึง
127.0.0.1       site2.local
127.0.0.1       site1.local
127.0.0.1       localhost

สุดท้าย restart apache

ไฟล์ C:\WINDOWS\System32\drivers\etc\host จะเป็นตัว resolve dns บนเครื่องเรา
.NET Developer, Cloud computing Developer
รับทำ component joomla, wordpress, drupal

awat

หรือเราจะไปเพิ่ม ที่ Apache\Apache2.2\conf\extra\httpd-vhosts.txt ก็ได้นะครับ

เพราะว่าใน htppd.txt มัน include httpd-vhosts.txt อยู่
.NET Developer, Cloud computing Developer
รับทำ component joomla, wordpress, drupal

togethers

[direct=http://www.skecherswomenshoes.co.cc]Skechers Women Shoes [/direct]
[direct=http://www.skechersmenshoes.co.cc]Skechers Men Shoes [/direct]
[direct=http://www.canon-digital-camera-review.co.cc]canon digital camera [/direct]
[direct=http://www.nikon-slr-camera-review.co.cc]nikon slr camera review[/direct]