apache 2.4添加虚拟主机
刚刚升级了wamps,把原来旧版的vhost覆盖过去,发现虚拟主机访问总是报403。
后来才指到,wamps升级apache到2.4.9了,apache 2.4以上版本中需要在目录下面添加 Require all granted,否则无论怎么访问都是403。另外Apache2.4.x可不用NameVirtualHost *:80,官网也不推荐使用。使用了在error.log中反而会出现警告“AH00548: NameVirtualHost has no effect and will be removed in the next release D:/xampp/apache/conf/extra/httpd-vhosts.conf:46”。
开启vhost功能一步忽略介绍,自行问度娘。
# Virtual Hosts # # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.4/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # <VirtualHost *:80> ServerAdmin admin@fengbingji.com DocumentRoot "d:/www/fengbingji.com" ServerName fengbingji.com ServerAlias www.a.com ErrorLog "logs/fengbingji.com.log" CustomLog "logs/fengbingji.com.log" common <Directory "d:/www/fengbingji.com"> Require all granted #如果开启了rewrite mod功能出现404,请增加以下代码 AllowOverride All </Directory> </VirtualHost>