Apache域名配置方法

1.打開C:/WINDOWS/system32/drivers/etc,看下面有沒有hosts文件,若存在在此文件尾加入兩行:
127.0.0.1 www.myweb1.com
127.0.0.1 www.myweb2.com
若不存在複製以下內容到記事本,將名字改爲hosts,去掉txt後綴名。
# 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
127.0.0.1 www.myweb1.com
127.0.0.1 www.myweb2.com
2.打開xampp安裝目錄:D:/xampp/apache /conf,找到文件httpd.conf,打開並查找“Virtual hosts” 確保下面一行沒有##號,修改後保存.
3.打開D:/xampp/apache/conf/extra,找到文件httpd-vhosts.conf,打開並查找 “NameVirtualHost”確保該行前面沒有#號,再在末尾加入以下幾行:
<VirtualHost *:80>
DocumentRoot /xampp/htdocs/123/bbs
ServerName www.myweb1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /xampp/htdocs/123/ucenter
ServerName www.myweb2.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /xampp/htdocs/
ServerName localhost
</VirtualHost>
修改後保存。
4.重啓Apache,在地址欄輸入域名www.myweb1.com 回車即可打開原來要輸入路徑才能打開的網頁。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章