之前一直用的是APMServ5.2.6这款服务器软件,今天安装用了下xampp。在网上看了下如何设置配置文件,简单总结下,具体如下:
在Apache中添加多域名支持:
1、设置httpd.conf文件:
注释掉“安装目录\xampp\apache\conf\httpd.conf“文件中 Include conf/extra/httpd-vhosts.conf前面的#。
2、设置httpd-vhosts.conf文件:
打开“安装目录\xampp\apache\conf\extra\httpd-vhosts.conf”,注释掉NameVirtualHost *:80前面的#,然后添加一下代码:
<VirtualHost *:80>
ServerAdmin webmaster@www.example.com
DocumentRoot “D:/xampp/htdocs/www.example.com” // 网站路径
ServerName www.example.com // 域名
ErrorLog “logs/www.example.com-error.log”
CustomLog “logs/www.example.com-access.log” combined
</VirtualHost>
主要就是设置好DocumentRoot和ServeName这两项,ServerAdmin,ErrorLog,CustomLog这三项也可以注释掉,没有影响。这样配置好后,重启Apache就行了。