一、打开tomcat安装目录下conf/server.xml这个文件
在server.xml文档中找到

</Engine>
</Service> 

接着添加上面添加以下内容(暂时先说分为三种方式):
第一种:
<Host name="www.haokan946.cn" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> 
<Context path="" docBase="www" debug="0" reloadable="true" crossContext="true"/> 
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www_5sai_log." suffix=".txt" 
timestamp="true"/> 
</Host>

以上的内容就是在Tomcat的webapps目录下新建一个www文件夹作为www.haokan946.cn这个域名的主目录

第二种:
<Host name="test.5sai.net.cn" debug="0" appBase="C://test/www" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="."/> 
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="test_5sai_access_log."

suffix=".txt" pattern="common" resolveHosts="false"/>
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="test_5sai_log." suffix=".txt" timestamp="true"/>
</Host>

以上内容的意思就是在C盘test文件夹下面建立一个www文件夹作为test.5sai.net.cn这个域名的主目录

第三种,如果是linux系统的/var/www作为test.5sai.net.cn这个域名的主目录的话内容如下:

<Host name="test.5sai.net.cn" debug="0" appBase="/var/www" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="."/> 
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="test_5sai_access_log."

suffix=".txt" pattern="common" resolveHosts="false"/>
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="test_5sai_log." suffix=".txt" timestamp="true"/>
</Host>

再补充一种
<Host name="www.haokan946.cn" debug="0" unpackWARs="true"> 
<Valve className="org.apache.catalina.valves.AccessLogValve" 
directory="/var/log/tomcat" prefix="www_5sai_access_log." suffix=".txt" 
pattern="common"/> 
<Logger className="org.apache.catalina.logger.FileLogger" 
directory="/var/log/tomcat" prefix="www_5sai_log." suffix=".txt" 
timestamp="true"/>

<Context path="" docBase="/var/www" debug="0" reloadable="true"/> 
</Host>

域名www.haokan946.cn的主目录为/var/www 该站点的所有访问LOG放在/ar/log/tomcat里面

测试:
windows用户打开C:/WINDOWS/system32/drivers/etc的hosts这个文件,
linux用户打开/ect的hosts文件或者vi /ect/hosts
修改内容如下
127.0.0.1 localhost
127.0.0.1 www.haokan946.cn
127.0.0.1 test.5sai.net.cn

然后打开浏览器直接输入网址测试!

linux中设置虚拟域名的更多相关文章

  1. linux 中配置假域名来测试

    1.linux中配置假域名 找到hosts文件进行编辑 命令:vim /etc/hosts 配置: #centos(本机IP)192.168.1.179 www.imooc.com(假域名,自己设置) ...

  2. linux下配置虚拟域名

    linux下配置虚拟域名 1.hosts文件位置! /etc/hosts 2.增加一行 127.0.0.1 xxxxx 3.修改apache中的vhosts vi /etc/httpd/extra/h ...

  3. 在linux中设置静态ip地址

    在linux中设置静态ip地址1.在终端中输入:vi /etc/sysconfig/network-scripts/ifcfg-eth0 2.开始编辑,填写ip地址.子网掩码.网关.DNS等[root ...

  4. wamp 2.5 开放访问权限和设置虚拟域名

    开放访问权限 D:\wamp\bin\apache\apache2.4.9\conf  里的 httpd.conf 搜索www   把 Require local 改为 Require all gra ...

  5. wamp2.5怎么设置虚拟域名

    换了台电脑~好不顺手.老大的机器上装的是wamp.几年没用差点连怎么设置虚拟域名都忘记了.自己写点东西~做个备忘吧. 首先,版本 然后在网上百度一堆七七八八的.做的时候没那么复杂.跟phpstudy差 ...

  6. Linux 中的虚拟网络接口

    独立博客地址:https://ryan4yin.space/posts/linux-virtual-network-interfaces/ 本文用到的字符画工具:vscode-asciiflow2 L ...

  7. Linux中设置服务自启动的三种方式

    有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s                       在/etc/rc.d/rc*.d目录中建立/e ...

  8. [转]Linux中设置服务自启动的三种方式

    from:http://www.cnblogs.com/nerxious/archive/2013/01/18/2866548.html 有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统 ...

  9. [Apache] 2.2与2.4版本在设置虚拟域名时的小差别

    Apache服务器配置虚拟步骤: 1.在httpd.conf中将附加配置文件httpd-vhosts.conf包含进来,接着在httpd-vhosts.conf中写入如下配置: #LoadModule ...

随机推荐

  1. RTF筛选工具

    您可借助此项筛选程序对具备.rtf扩展名的文档进行爬行遍历,以便通过搜索结果对目标文档加以访问调用.管理员应先在相关服务器上对程序文件进行注册,方可运行此项工具. 用户下载.安装并使用相关代码的行为即 ...

  2. vue定义组件

    1.定义组件 2.在App.vue里引入Home组件 home代码 <template> <div>home</div> </template> < ...

  3. html、css、js分工,内核,html头,html表单

    html:内容css:样式js:交互 内核 浏览器控制台输入navigator.userAgent,回车显示出内核"Mozilla/5.0 (Windows NT 6.1; WOW64) A ...

  4. 连接超时(connect timed out)和读取超时(Read timed out)

    设置连接超时和读取超时方法: RequestConfig config=RequestConfig.custom() .setConnectTimeout(10000) // 设置连接超时时间 10秒 ...

  5. NaN、null、undefined的那些事

    一.NaN , NaN, 'abc', false] let newArray = JSON.parse(JSON.stringify(arr)) // [1, null, 'abc', false] ...

  6. Vagrant 手册之网络 - 私有网络 private network

    原文地址 Vagrantfile 配置文件中私有网络的标识符:private_network,例如: config.vm.network "private_network", ty ...

  7. Jenkins持续集成_02_添加python项目&设置定时任务

    前言 自动化测试脚本编写后,最终目的都是持续集.持续集成可以实现一天多次部署运行自动化脚本,对功能进行不断监控测试.由于小编使用python编写的自动化脚本,这里仅讲解下如何在Jenkins中添加py ...

  8. 微信小程序这一块(下)

    1.小程序分为两部分 :页面.组件 2.小程序中如何定义自定义组件? 凡是通过Page创建的都是页面,而通过Components创建的都是组件 当组件创建成功后,在需要使用的页面进行引入,(找到页面的 ...

  9. String.prototype.includes

    if (!String.prototype.includes) {   String.prototype.includes = function(search, start) {     'use s ...

  10. df认识

    import pandas as pd #自己创建一个df df = pd.DataFrame({ ,,], 'col2':["zs",'li','zl'], 'col3':[3. ...