zoukankan      html  css  js  c++  java
  • IIS、apache、tomcat服务器虚拟主机配置

    准备阶段

    首先我们有一个域名  xxx.com;(注,两个一级域名不相同也可以)
    有两个二级域名   priject.xxx.com 和 movie.xxx.com
    有一台主机 ,现在假设访问主机电脑
    

    IIS服务器虚拟主机配置方法

    1、在IIS中添加网站
    其中 绑定一栏中的主机名为 priject.xxx.com,在分配好网站的文件路径

    2、添加isapi筛选器
    其中可执行文件位置为php的安装位置

    3、处理程序映射->添加脚本映射

    4、最后重启IIS服务器,就可以用域名访问了;再添加站点,同样的步骤。

    tomcat服务器虚拟主机配置方法
    在Engine节点下增加host节点

    <Host name="priject.xxx.com"  appBase="webapps/priject"
                unpackWARs="true" autoDeploy="true">
    
            <!-- SingleSignOn valve, share authentication between web applications
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
    
            <!-- Access log processes all example.
                 Documentation at: /docs/config/valve.html
                 Note: The pattern used is equivalent to using pattern="common" -->
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log." suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    
    </Host>
    <Host name= "movie.xxx.com"  appBase="webapps/movie"
                unpackWARs="true" autoDeploy="true">
    
            <!-- SingleSignOn valve, share authentication between web applications
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
    
            <!-- Access log processes all example.
                 Documentation at: /docs/config/valve.html
                 Note: The pattern used is equivalent to using pattern="common" -->
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log." suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    
    </Host>
    

    注在webapps目录下的movie要创建ROOT目录才可以,而且ROOT必须大写。在ROOT目录先放置jsp代码。

    tomcat会根据主机名称自动寻找相应的目录去访问

    apache服务器虚拟主机配置方法

    打开httpd.conf文件
    去掉LoadModule vhost_alias_module modules/mod_vhost_alias.so
    这句前面的#号

    Include conf/extra/httpd-vhosts.conf这句前面的#号

    Include conf/extra/httpd-vhosts.conf这句在httpd.conf文件底部

    然后打开Apache2.2confextra下的httpd-vhosts.conf文件,加入如下代码

    #配置自己的虚拟主机
    <VirtualHost *:80>
        #网站目录,如果在www目录下的php目录,下面    #就填写F:/www/php
        DocumentRoot "D:/www/网站目录" 
        #域名
        ServerName  priject.xxx.com
        #这里配置欢迎首页面
        DirectoryIndex index.html index.htm index.php
        <Directory />
        Options FollowSymLinks
        #不允许别人修改我们的页面
        AllowOverride None
        #设置访问权限
        order allow,deny
        Allow from all
        </Directory>   
    </VirtualHost>
    <VirtualHost *:80>
        #网站目录,如果在www目录下的php目录,下面    #就填写F:/www/php
        DocumentRoot "D:/www/网站目录" 
        #域名
        ServerName  movie.xxx.com
        #这里配置欢迎首页面
        DirectoryIndex index.html index.htm index.php
        <Directory />
        Options FollowSymLinks
        #不允许别人修改我们的页面
        AllowOverride None
        #设置访问权限
        order allow,deny
        Allow from all
        </Directory>   
    </VirtualHost>
    

    原文链接:https://cloud.tencent.com/developer/article/1370539

  • 相关阅读:
    利用IDE自动生成Logger变量
    浏览器跨域请求
    linux shell 跟踪网站变动
    linux shell 查找网站中无效的链接
    linux shell 网页相册生成器
    Shell帮你掌管上千台服务(多线程)
    Ansible小实例
    Shell监控公网IP-变化邮件报警
    ffmpeg顺时针或逆时针旋转视频90,180度
    Download youtube videos with subtitles using youtube-dl
  • 原文地址:https://www.cnblogs.com/hleisurely/p/13378896.html
Copyright © 2011-2022 走看看