• 【技术宅7】一个或多个虚拟主机配置方法


    一、虚拟主机配置方法

           1,在文件C:/windows/system32/drivers/etc/hosts 加上 

                  127.0.0.1   你的域名 

          

           2,在 httpd.conf里的去掉#

              Include conf/extra/httpd-vhosts.conf

            

           3,在apache目录里找到 conf/extra/httpd-vhosts.conf 把里面的内容都注释(每一行前面加 #)然后添加后面的代码:

                   NameVirtualHost *:80  

                   <VirtualHost 127.0.0.1:80>

                         ServerAdmin admin@admin.com     #你的邮箱地址 

                         DocumentRoot "C:/www.a.com"     # 配置域名对应的文件夹路径

                         ServerName www.a.com            #配置对应的域名 

                   

                         <Directory "C:/www.a.com">      <--配置文件夹相关权限

                                Options Indexes FollowSymLinks

                                AllowOverride None

                                Order allow,deny

                                Allow from all

                         </Directory>                    -->

                 

                         ErrorLog "logs/www.a.com-error.log"

                         CustomLog "logs/www.a.com-access.log" common

                  </VirtualHost>

     

    二、一个ip绑定多个域名  

           方法一:通过端口来区分不同的站点

                         ?与配置虚拟主机一样先配置一个站点

                         1、启用在 httpd.conf 里的Include conf/extra/httpd-vhosts.conf ,即把前面的#去掉  // Virtual hosts 虚拟主机的意思                 

                         2、在windows下面的host文件:C:/windows/system32/drivers/etc/hosts 添加域名 //127.0.0.1 www.a.html               

                         3、在Apache2.2confextra目录下打开httpd-vhosts.conf文件,在里面进行如下配置

                                <VirtualHost 127.0.0.1:80>

                                       DocumentRoot “d:/myblog”

                                       DirectoryIndex index.html    

                                         <Directory "C:/www.a.com">    

                                              Options Indexes FollowSymLinks

                                              AllowOverride None 

                                              Order allow,deny   

                                              Allow from all

                                       </Directory>            

                                </VirtualHost>

                               

                         ?配置第二个站点

                         1、在Apache2.2confextra目录下打开httpd-vhosts.conf文件,在里面进行如下配置

                                <VirtualHost 127.0.0.1:81>

                                       DocumentRoot “d:/myweb”

                                       DirectoryIndex index.html    

                                         <Directory "C:/www.a.com">    

                                              Options Indexes FollowSymLinks

                                              AllowOverride None 

                                              Order allow,deny   

                                              Allow from all

                                       </Directory>            

                                </VirtualHost>

                         2、让apache监听81端口,即在apache的httpd.conf中的listen添加:Listen 81

                         3、在windows下面的host文件:C:/windows/system32/drivers/etc/hosts 添加域名 //127.0.0.1 www.b.html

                                【注意:以端口区分的话,在浏览器输入地址时,需要在地址后面输入端口,否则无法执行】

          

          

           方法二:通过ServerName端区分不同的站点

                         第一步:站点名称上面的一样

                                d:/myblog   www.a.html

                                d:/myweb   www.b.html

                               

                         第二步:在httpe-vhosts.conf中配置

                         <VirtualHost *:80>                       //这里的127.0.0.1要改成*

                                DocumentRoot “d:/myblog”

                                ServerName www.a.html

                                DirectoryIndex index.html    

                            <Directory "C:/www.a.com">    

                                  Options Indexes FollowSymLinks

                                  AllowOverride None 

                                  Order allow,deny   

                                  Allow from all

                           </Directory>            

                         </VirtualHost>

                 

                         <VirtualHost *:81>                       //这里的127.0.0.1要改成*

                            DocumentRoot “d:/myweb”

                            ServerName www.b.html

                            DirectoryIndex index.html    

                            <Directory "C:/www.b.com">    

                                 Options Indexes FollowSymLinks

                                 AllowOverride None 

                                 Order allow,deny   

                                 Allow from all

                            </Directory>            

                         </VirtualHost>

                               

                     第三步:在windows下面的host文件:C:/windows/system32/drivers/etc/hosts  添加你的域名

                         127.0.0.1 www.a.html

                         127.0.0.1 www.b.html

    我发现了一个奇怪的现象,就是经常赞我的人,特别是支持我的人,都在不久后做成了如下事情:1、恋爱成功了;2、生意谈成了;3、事业有成了;4、升官发财了;5、心情舒畅了;6、家庭和睦了;7、身体健康了;8、万事如意了
  • 相关阅读:
    Linux的命令、用户、权限管理
    Java中快捷键
    数组的学习
    Java中方法定义和调用的学习
    java中的标识符、修饰符、关键字
    MYSQL的学习
    JavaScript小白教程2
    navicat中选择utf-8时的困惑
    python小白教程
    英语单词
  • 原文地址:https://www.cnblogs.com/zhuyibo/p/3984894.html
Copyright © 2020-2023  润新知