Apache 虚拟主机的配置方法总结:
虚拟主机
1. 在httpd.conf中找到Include conf/extra/httpd-vhosts.conf 把前面的#去除
2. 添加监听如:Listen 8080
Listen 192.168.0.100:80
3. 删除或注掉DocumentRoot "D:/Apache2.2/htdocs"
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "D:/Apache2.2/htdocs"
4. 在配置extra/httpd-vhosts.conf时,如果要保留原来httpd.conf中默认的访问目录和域名,必须为默认域名也创建一个virtualHost,样例如下(监听端口是8080):
5. httpd-vhosts.conf配置如下:
NameVirtualHost *:8080
NameVirtualHost 192.168.0.100:80
在文档底部接着添加:
<VirtualHost 192.168.0.100:80>
ServerName njumasoft
DocumentRoot F:/php/UmasoftFrw
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Satisfy all
</Directory>
DirectoryIndex index.html index.php
CustomLog "logs\njumasoft-access.log" common
ErrorLog "logs\njumasoft-error.log"
</VirtualHost>
<VirtualHost 192.168.0.100:8080>
ServerName mysqld
DocumentRoot D:/Apache2.2/htdocs
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Satisfy all
</Directory>
DirectoryIndex index.html index.php
CustomLog "logs\mysqld-access.log" common
ErrorLog "logs\mysqld-error.log"
</VirtualHost>
其它设置参见:/Apache/ApacheMenu/vhosts/index.html
虚拟目录
1.找到"conf/httpd.conf" 文件,按如下示例设置:
<IfModule dir_module>
DirectoryIndex index.html index.html.var index.php
Alias /mysql D:/Apache2.2/htdocs/phpMyAdmin
<Directory D:/Apache2.2/htdocs/phpMyAdmin>
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
注:以上配置均需重启Apache。