Tomcat虚拟主机
程序员文章站
2022-07-03 14:12:59
...
1.Tomcat部署好以后,一些参数解释如下:
●bin
存放启动和关闭 Tomcat 的脚本文件,比较常用的是 catalina.sh、startup.sh、
shutdown.sh 三个文件●conf
存放 Tomcat 服务器的各种配置文件,比较常用的是 server.xml、context.xml、
tomcat-users.xml、web.xml 四个文件。●lib
存放 Tomcat 服务器的 jar 包,一般不作任何改动,除非连接第三方服务,比如 redis,
那就需要添加相对应的 jar 包●logs
存放 Tomcat 日志●temp
存放 Tomcat 运行时产生的文件●webapps
存放项目资源的目录●work
Tomcat 工作目录,一般清除 Tomcat 缓存的时候会使用到
2.安装并配置DNS服务
[aaa@qq.com bin]# yum install bind -y
//主配置文件
[aaa@qq.com bin]# vim /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
//区域配置文件
[aaa@qq.com bin]# vim /etc/named.rfc1912.zones
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
//区域数据配置文件
[aaa@qq.com bin]# cd /var/named/
[aaa@qq.com named]# cp -p named.localhost kgc.com.zone
[aaa@qq.com named]# vim kgc.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.35.134
[aaa@qq.com named]# cp -p kgc.com.zone accp.com.zone
开启服务
[aaa@qq.com named]# systemctl start named
3.在测试机win7上,测试下保证能够域名解析
4.创建 kgc 和 accp 项目目录和文件
[aaa@qq.com named]# cd /usr/local/tomcat/webapps/
[aaa@qq.com webapps]# ls
docs examples host-manager manager ROOT
[aaa@qq.com webapps]# mkdir kgc accp
[aaa@qq.com webapps]# ls
accp docs examples host-manager kgc manager ROOT
[aaa@qq.com webapps]# cd kgc
[aaa@qq.com kgc]# vim index.jsp
<h1>this is kgc web</h1>
[aaa@qq.com kgc]# cd ../accp/
[aaa@qq.com accp]# vim index.jsp
<h1>this is accp web</h1>
5.修改 Tomcat 主配置文件并重启服务
[aaa@qq.com accp]# vim /usr/local/tomcat/conf/server.xml
<Host name="www.kgc.com" appBase="/usr/local/tomcat/webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context docBase="/usr/local/tomcat/webapps/kgc"
path="" reloadable="true" />
</Host>
<Host name="www.accp.com" appBase="/usr/local/tomcat/webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context docBase="/usr/local/tomcat/webapps/accp"
path="" reloadable="true" />
</Host>
[aaa@qq.com conf]# shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[aaa@qq.com conf]# startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
6.测试网页
(1)使用浏览器访问 http://www.kgc.com:8080 页面显示This is kgc web
(2)使用浏览器访问 http://www.accp.com:8080 页面显示This is accp web
上一篇: Hbuilder less自动编译
推荐阅读
-
CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档
-
request.getSession().getServletContext().getRealPath("upload/" ); 获取不到 tomcat 服务器目录
-
apache中使用mod_gnutls模块实现多个SSL站点配置(多个HTTPS协议的虚拟主机)
-
用虚拟主机做的网站如何迁移
-
Eclipse中serverRuntimeEnvironment中没有Tomcat选项问题解决办法
-
图解linux安装tomcat(附常用命令)
-
Centos7.3安装和配置Tomcat8
-
购买虚拟主机10个注意事项
-
Jsp和PHP共用80端口整合Apache和Tomcat(访问时无需加端口号)
-
Linux 安装JDK Tomcat MySQL的教程(使用Mac远程访问)