Windows环境下apache 配置(多域名访问多目录站点),apache站点


一、基础概念

   1.Apache 是一个web服务器

   2.localhost 与127.0.0.1的意思:

        localhost 是指 “本地服务器”,127.0.0.1是本机地址

        他们的解析通过本机的host文件,windows自动将localhost解析为127.0.0.1


二、基本配置

        把Apache安装到E:\Apache24目录下,安装完成后默认的网站根目录为E:\Apache24\htdocs,我们可以在该目录下建立文件夹MySite,然后在浏览器输入http://localhost/MySite   或者127.0.0.1/MySite 就可以访问该站点了。

        然而有时候我们想帮站点放到其他目录,或者通过多个域名访问多个目录的站点,我们就需要配置虚拟目录了。


三、虚拟配置

    1.进入C:\Windows\System32\drivers\etc目录,编辑hosts文件,设置域名

       如127.0.0.1   dev.yunchou.com

            127.0.0.1   local.yunchou.com

     2.进入E:\Apache24\conf目录,编辑httpd.conf文件,找到# Include conf/extra/httpd-vhosts.conf,取得前面的#,让httpd-vhosts.conf生效

     3.进入E:\Apache24\conf\extra目录,编辑httpd-vhosts.conf文件,设置虚拟站点

         添加

  <VirtualHost *:80>
    DocumentRoot "E:/ycode"  
    ServerName dev.yunchou.com   
    ErrorLog "logs/yunchou-drupal-error_log"
    CustomLog "logs/yunchou-drupal-access_log" common
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
  
</VirtualHost>


<VirtualHost *:80>

    DocumentRoot "E:/ycode/yunchou_com/web"  
    ServerName local.yunchou.com   
    ErrorLog "logs/yunchou-drupal-error_log"
    CustomLog "logs/yunchou-drupal-access_log" common
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
  
</VirtualHost>

 

    4.重启Apache

    5.通过不同域名可以访问不同目录的站点


相关内容

    暂无相关文章