apache2.4 虚拟主机配置

Posted sivkun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache2.4 虚拟主机配置相关的知识,希望对你有一定的参考价值。

网上教程很多,仅记录我的配置,可供参考

一、修改httpd.conf

打开appserv的安装目录,找到httpd.conf文件,分别去掉下面两行文字前面的#号。 

[plain] view plain copy
  1. #LoadModule vhost_alias_module modules/mod_vhost_alias.so  

去掉#意思是启用apache的虚拟主机功能。 

[plain] view plain copy
  1. #Include conf/extra/httpd-vhosts.conf  

去掉这一行的#意思是从conf/extra/httpd-vhosts.conf这个文件导入虚拟主机配置

二、修改httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:\developer\Apache24\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:\developer\www\a.sivkun.com"
    ServerName a.sivkun.com
    #ServerAlias www.dummy-host.example.com
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
        <Directory "E:\developer\www\a.sivkun.com">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:\developer\www\b.sivkun.com"
    ServerName b.sivkun.com
    <Directory "E:\developer\www\b.sivkun.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:\developer\www\c.sivkun.com"
    ServerName c.sivkun.com
    <Directory "E:\developer\www\c.sivkun.com">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

三、修改hosts

windows路径:C:\Windows\System32\drivers\etc\hosts

127.0.0.1 localhost
127.0.0.1 a.sivkun.com
127.0.0.1 b.sivkun.com
127.0.0.1 c.sivkun.com

参考了:http://blog.csdn.net/zm2714/article/details/8351342

以上是关于apache2.4 虚拟主机配置的主要内容,如果未能解决你的问题,请参考以下文章

apache2.4.X虚拟主机配置

Linux系统下Apache2.4.6配置虚拟主机

apache2.4 虚拟主机配置

apache2.4配置虚拟目录

apache2.4以上版本配置虚拟主机

apache2.4.27配置虚拟主机