Windows服务器下Apache基于域名的虚拟主机配置

发布时间:2021-09-16

  下面我想记录下Windows服务器下Apache基于域名的虚拟主机配置,仅做参考

  此配置是在Windows服务器下Apache的安装步骤 基础之上的。

  配置思路:修改f,Include 一个基于域名的主机配置文件,配置文件中

   指定域名,主机,www.lu0.com网站根目录等内容,重启测试即可。本例子用

   作为域名

  

  配置httpd.conf

  ----------------------------------

  # Virtual hosts begin
#Include conf/extra/httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
Include conf/extra/vhosts/*.conf

  ----------------------------------
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

<Directory D:/server/Apache24/cgi-bin>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

  ----------------------------------

  配置

<VirtualHost *>
<Directory E:/htdocs/
Options -Indexes FollowSymLinks
</Directory>
ServerAdmin admin@
DocumentRoot E:/htdocs/
ServerName
ErrorLog logs/
php_admin_value open_basedir E:htdocs
</VirtualHost>

  ----------------------------------

   需要修改Directory,否则会无法打开网站,域名需要解析到服务器的ip地址上,

   最后我们可以编辑一个<?php phpinfo(); ?>来校验我们安装是否成功!如下图:

  

注册即送1000元现金券