s0ct0j0c
23-04-2011, 06:16 PM
Hôm trước share cách chạy asp trên ITVNN hôm nay mình tiếp tục share cách để add domain vào host xampp
Virtual Hosts
Mở file hosts ở C:\windows\system32\drivers\etc\hosts bằng notepad bạn nhé!
VD đây mình làm 1 tên miền giả trỏ vào localhost: Các bạn thêm dòng này vào cuối
127.0.0.1 clientA.local
Save and close file hosts.
Dùng Notepad mở file C:\xampp\apache\conf\extra\httpd-vhosts.conf
Thêm vào cuối:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
ServerName clientA.local
<Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost> Lưu ý bước này thì nhớ tùy chỉnh đường dẫn hơp theo cấu hình cài đặt ở máy mình nhé.
Save and close file, rồi restart Apache bằng XAMPP control panel.
Mở Web browser và đánh vào địa chỉ virtual host. VD: lúc này mình tạo 1 tên miền giả trong máy là http://clientA.local/.
Bạn sẽ thấy home page của mình được đặt ở đó.
Nhiều Virtual Hosts
Nếu bạn có nhiều tiên miền thì cũng tương tự vậy VD: mình làm 1 domain thứ 2 là
127.0.0.1 clientB.local
C:\xampp\apache\conf\extra\httpd-vhosts.conf thì file sẽ có dạng như sau:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
ServerName clientA.local
<Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientB\website"
ServerName clientB.local
<Directory "C:\Documents and Settings\Me\My Documents\clientB\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>Chúc mấy pác thành công share only on ITVNN.NET
Bài trước nó biến đâu rùi không biết tìm hoài không thấy mất công ghi dễ sợ :MatCuoi (12):
Virtual Hosts
Mở file hosts ở C:\windows\system32\drivers\etc\hosts bằng notepad bạn nhé!
VD đây mình làm 1 tên miền giả trỏ vào localhost: Các bạn thêm dòng này vào cuối
127.0.0.1 clientA.local
Save and close file hosts.
Dùng Notepad mở file C:\xampp\apache\conf\extra\httpd-vhosts.conf
Thêm vào cuối:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
ServerName clientA.local
<Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost> Lưu ý bước này thì nhớ tùy chỉnh đường dẫn hơp theo cấu hình cài đặt ở máy mình nhé.
Save and close file, rồi restart Apache bằng XAMPP control panel.
Mở Web browser và đánh vào địa chỉ virtual host. VD: lúc này mình tạo 1 tên miền giả trong máy là http://clientA.local/.
Bạn sẽ thấy home page của mình được đặt ở đó.
Nhiều Virtual Hosts
Nếu bạn có nhiều tiên miền thì cũng tương tự vậy VD: mình làm 1 domain thứ 2 là
127.0.0.1 clientB.local
C:\xampp\apache\conf\extra\httpd-vhosts.conf thì file sẽ có dạng như sau:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
ServerName clientA.local
<Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Documents and Settings\Me\My Documents\clientB\website"
ServerName clientB.local
<Directory "C:\Documents and Settings\Me\My Documents\clientB\website">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>Chúc mấy pác thành công share only on ITVNN.NET
Bài trước nó biến đâu rùi không biết tìm hoài không thấy mất công ghi dễ sợ :MatCuoi (12):