您的位置:首页 > 运维架构 > Apache

本机上配置Apache多站点

2012-06-13 10:07 232 查看
步骤1: 到Apache的安装目录下,打开httpd.conf配置文件。在文件结尾假如这段:

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>

 DocumentRoot C:\Users\Administrator\Documents\CRS_FILE\Satoo\public 

 ServerName saytoo

</VirtualHost>

<Directory "C:\Users\Administrator\Documents\CRS_FILE\Satoo\public">

 AllowOverride All

 Order allow,deny

 Allow from all

</Directory>

<VirtualHost 127.0.0.1> 

 DocumentRoot E:\kindergarten\public 

 ServerName kindergarten

</VirtualHost>

<Directory "E:\kindergarten\public"> 

 AllowOverride All

 Order allow,deny

 Allow from all

</Directory>

上面这段配置了两个站点,一个是saytoo, 一个是kindergarten。  DocumentRoot  和Directory 上写上项目路径,ServerName 是站点名,

步骤2: C:\Windows\System32\drivers\etc目录下打开hosts文件。

  在这里

# localhost name resolution is handled within DNS itself.

# 127.0.0.1       localhost

# ::1             localhost

127.0.0.1 saytoo

127.0.0.1 kindergarten

加入地址映射。注意: 这里的域名(saytoo 和kindergarten)要对应步骤1中的ServerName 

步骤3: 保存重启Apache, 浏览器地址栏输入 http://saytoo   或 http://kindergarten 即可访问.

完事!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息