码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat

时间:2019-08-24 15:18:22      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:admin   try   protoc   monitor   openjdk   编辑   moni   using   mysq   

tomcat安装

第一步:官网下载安装包
https://tomcat.apache.org/

第二步:上传安装包
[root@ken ~]# rz 没有 lrzsz 需要下载 yum install lrzsz -y
[root@ken ~]# ls
apache-tomcat-9.0.17.zip fuhai-jpress-alpha.zip 没有 unzip 需要下载 yum install unzip -y
[root@ken ~]#

第三步:解压安装包
[root@ken ~]# unzip apache-tomcat-9.0.17.z
第四步:移动文件到/usr/local
[root@ken ~]# mv apache-tomcat-9.0.17 /usr/local/tomcat 移动并且改名

第五步:加执行权限 查看有没有权限 cd / usr/local/tomcat/bin/ 查看权限 ls -l
都是没有执行权限
[root@ken local]# chmod -R +x tomcat/ Tomcat 后面加 / 表示tomcat下面所有文件增加权限

第六步:下载java环境(jdk)
[root@ken bin]# yum install java -y #java-1.8.0-openjdk

第七步:启动tomcatcd cd /usr/local/tomcat/bin 然后开启tomcat的开启文件
[root@ken bin]# ./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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

第八步:检测端口
[root@ken bin]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

第九步:浏览器访问
ip:8080


第十步:关闭tomcat
[root@ken bin]# ./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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar


tomcat网站根目录

webapps

tomcat日志

logs/catalina.out
tomcat主配置文件

[root@ken tomcat]# vim conf/server.xml /usr/local/tomcat/conf/server.xml

<Server port=”8005″ shutdown=”SHUTDOWN”>
<Connector port=”8080″ protocol=”HTTP/1.1″
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
<Host name=”localhost” appBase=”webapps”

8005端口接收shutdown指令 cd
[root@ken tomcat]# telnet 127.0.0.1 8005
Trying 127.0.0.1…
Connected to 127.0.0.1.
Escape character is ‘^]’.
SHUTDOWN
Connection closed by foreign host.
[root@ken tomcat]#
[root@ken tomcat]#
[root@ken tomcat]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

vim /etc/profile.d/tomcat.sh 通用于apache
编写脚本
#!/bin/bash
export PATH=/usr/local/tomcat/bin/:$PATH
开启端口 startup.sh 关闭端口 shutdown.sh


tomcat多实例部署-三台

第一步:复制两份tomcat文件
[root@ken local]# ls
bin etc games include lib lib64 libexec sbin share src tomcat
[root@ken local]# cp tomcat tomcat1 -a
[root@ken local]# cp tomcat tomcat2 -a
[root@ken local]# ls
bin etc games include lib lib64 libexec sbin share src tomcat tomcat1 tomcat2

第二步:修改tomcat1端口cp cd /usr/local/tomcat1/conf/server.xml
只需要修改两处:
8005–》8006c:
8080–》8081
ml
第三步:修改tomcat2端口
只需要修改两处:
8005–》8007
8080–》8082

第四步:启动各个tomcat实例
[root@ken local]# tomcat/bin/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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@ken local]# tomcat1/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat1
Using CATALINA_HOME: /usr/local/tomcat1
Using CATALINA_TMPDIR: /usr/local/tomcat1/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar
Tomcat started.
[root@ken local]# tomcat2/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat2
Using CATALINA_HOME: /usr/local/tomcat2
Using CATALINA_TMPDIR: /usr/local/tomcat2/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar
Tomcat started.

第五步:查看端口
[root@ken local]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 100 :::8081 :::*
LISTEN 0 100 :::8082 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

第六步:访问网站


tomcat集群部署

nginx服务器:192.168.64.5
tomcat集群: 192.168.64.4

第一步:部署tomcat后端节点


第二步:编辑nginx配置文件
upstream ken {
server 192.168.64.4:8080 weight=2 max_fails=2 fail_timeout=2;
server 192.168.64.4:8081 weight=4 max_fails=2 fail_timeout=2;
server 192.168.64.4:8082 weight=1 max_fails=2 fail_timeout=2;
}


location / {
proxy_pass http://ken;
}

第三步:检测nginx配置并启动
[root@ken yum.repos.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@ken yum.repos.d]# systemctl restart nginx

第四步:浏览器访问
访问的时候nginx服务器


tomcat上线jpress博客系统

第一步:下载jpress
https://gitee.com/fuhai/jpress/blob/alpha/wars/jpress-web-newest.war

第二步:上传软件包并解压
[root@ken ROOT]# ls
fuhai-jpress-alpha.zipcd
[root@ken ROOT]# unzip fuhai-jpress-alpha.zip

第三步:复制
[root@ken ROOT]# cp jpress/wars/jpress-web-newest.war . 复制到当前目录
[root@ken ROOT]# ls
fuhai-jpress-alpha.zip jpress jpress-web-newest.war

第四步:解压jpress-web-newest.war
[root@ken ROOT]# unzip jpress-web-newest.war

第五步:浏览器访问
输入ip:8080/jpress

第六步:下载数据库并启动
[root@ken ROOT]# yum install mariadb-server -y
[root@ken ROOT]# systemctl restart mariadb


第七步:创建数据库和用户
[root@ken ROOT]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]> create database ken;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on *.* to ken@’localhost’ identified by ‘123’;
Query OK, 0 rows affected (0.00 sec)

第八步:浏览器输入数据库相关的库和用户


第九步:重启tomcat
[root@ken bin]# ./shutdown.sh 重新启动Tomcat
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@ken bin]# ./startup.sh 重新启动Tomcat
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

第十步:再次访问浏览器
就可以访问了
192.168.194.8:8080/admin 可以编辑网站

tomcat

标签:admin   try   protoc   monitor   openjdk   编辑   moni   using   mysq   

原文地址:https://www.cnblogs.com/it-peng/p/11404436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!