MangVN

https://mangvn.org


Tạo virtualhost cho server apache được cài trên nền windows XP

Đối với những người thiết kế web, chắc đường link: http://localhost/nukeviet/ , http://localhost/forum/ rất quen thuộc. Nó dẫn bạn đến trang chủ của portal nukeviet mà bạn đã cài từ trước trong máy tính. Đã bao giờ bạn nghĩ, làm thế nào để chỉ việc gõ link: http://mysite.com là có thể truy cập đến site nukeviet. Gõ link: http://myforum.com - đến diễn đàn mà bạn đã cài. Xin mách nhỏ các bạn phương pháp tạo virtualhost cho server apache được cài cho windows XP.

- Như hướng dẫn cách cài đặt webserver Apache, Perl, MySql, Php trên nền
windows XP (

http://nukevn.com/forums/showthread.php?t=4
), thư mục D:wwwpublic_html
là thư mục chứa các files, folders của website. Để nukeviet nằm ở một vị trí
riêng, forum nằm ở một vị trí riêng, bạn hãy tạo:

D:www
ukevietpublic_html

D:www
ukevietcgi

D:wwwforumpublic_html

D:wwwforumcgi



- Mở file: httpd.conf trong thư mục D:Apacheconf, thêm xuống dưới cùng:



Trích:








ServerAdmin

webmaster@mysite.com


ServerName mysite.com

DocumentRoot "D:/www/nukeviet/public_html"

ScriptAlias /cgi/ "D:/www/nukeviet/cgi/"

ErrorLog D:/www/nukeviet/error.log

CustomLog D:/www/nukeviet/access.log common







ServerAdmin

webmaster@myforum.com


ServerName myforum.com

DocumentRoot "D:/www/forum/public_html"

ScriptAlias /cgi/ "D:/www/forum/cgi/"

ErrorLog D:/www/forum/error.log

CustomLog D:/www/forum/access.log common







- Mở file: C:WINDOWSsystem32driversetchosts bằng chương trình notepad,
bạn sẽ thấy nội dung như sau:



Trích:






# Copyright (c) 1993-1999 Microsoft Corp.

#

# This is a sample HOSTS file used by Microsoft TCP/IP for
Windows.

#

# This file contains the mappings of IP addresses to host names.
Each

# entry should be kept on an individual line. The IP address
should

# be placed in the first column followed by the corresponding
host name.

# The IP address and the host name should be separated by at
least one

# space.

#

# Additionally, comments (such as these) may be inserted on
individual

# lines or following the machine name denoted by a '#' symbol.

#

# For example:

#

# 102.54.94.97 rhino.acme.com # source server

# 38.25.63.10 x.acme.com # x client host



127.0.0.1 localhost





Hãy viết thêm xuống dưới:



Trích:






127.0.0.2 mysite.com

127.0.0.3 myforum.com



Lưu file và khởi động lại máy.



- Kiểm tra:

Tạo file index.php tại thư mục D:www
ukevietpublic_html với nội dung
sau:



PHP Code:






echo "Welcome to Mysite.com";


?>






và D:wwwforumpublic_html với nội dung:



PHP Code:






echo "welcome to Myforum.com";


?>






Mở trình duyệt, gõ:


http://mysite.com


http://myforum.com
. Nếu hiển thị dòng chữ “Welcome to Mysite.com” hoặc
"Welcome to Myforum.com" trên trình duyệt, tức là bạn đã tạo thành công
virtualhost rồi.

Việc tiếp theo là cài portal nukeviet vào thư mục D:www
ukevietpublic_html
và forum nào đó (phpbb chẳng hạn) vào thư mục D:wwwforumpublic_html.

Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây