Apache vhost配置

来源:互联网 发布:观澜网络官网 编辑:程序博客网 时间:2024/05/16 06:51

1.用记事本打开apache目录下httpd文件,找到如下模块。

# Virtual host

#Include conf/extra/httpd-vhosts.conf


将include前的#号去掉,使其支持vhosts功能


2.打开 host文件增加一行,作用为将制定的域名指向本地服务器。


127.0.0.1 www.hys.com


3.打开conf/extra/httpd-vhosts.conf 这个文件   更改如下:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.


#
# Use name-based virtual hosting.
#
NameVirtualHost *:80


<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "D:\WORK\hys"
ServerName hys.com
ServerAlias www.hys.com
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" common
<Directory D:\WORK\hys>
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
</VirtualHost>


<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "D:\WORK\AppServ\www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" common
<Directory D:\WORK\AppServ\www>
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
</VirtualHost>


最后保存所有更改  重启电脑。

重启后则可以

D:\WORK\hys  用www.hys.com访问

D:\WORK\AppServ\www 用localhost访问

0 0
原创粉丝点击