步骤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 即可访问.
完事!