CentOS7部署tomcat8

CentOS7部署tomcat8


 

1.官网下载

 下载二进制包,源码包不完整

[root@localhost ~]# wget https://repo.huaweicloud.com/apache/tomcat/tomcat-8/v8.5.70/bin/apache-tomcat-8.5.70.tar.gz               (华为镜像站)

2.解压部署

[root@localhost ~]# tar xvzf apache-tomcat-8.5.70.tar.gz -C /usr/local/
[root@localhost ~]# mv /usr/local/apache-tomcat-8.5.70/ /usr/local/tomcat

3.定义Tomcat所需环境变量:

[root@localhost ~]# vim /etc/profile //定义Tomcat环境变量
CATALINA_HOME=/usr/local/tomcat //Tomcat安装目录
export CATALINA_HOME
[root@localhost ~]# source /etc/profile

4.启动关闭tomcat:

[root@localhost ~]# /usr/local/tomcat/bin/startup.sh 
[root@localhost ~]# /usr/local/tomcat/bin/shutdown.sh

5.开机自启:

写入/etc/rc.local文件,并添加 +x 执行权限

[root@localhost ~]# vim /etc/rc.local 
export JAVA_HOME=/usr/local/jdk1.7.0_51                             (必须指定jdk路径)
/opt/tomcat7-1/bin/catalina.sh start
/usr/redis/redis-server  /usr/redis/redis.conf
memcached -d -m 1024 -u memcached -d -l 10.0.1.12 -p 11211 -c 4096 -t 64

[root@localhost ~]# chmod +x /etc/rc.local
 

配置tomcat的角色和用户(暂时用不到):
在tomcat目录conf文件夹下tomcat-users.xml

<role rolename="manager-gui"/>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin,manager,manager-script"/> 

6.测试tomcat可用性:

浏览器: 192.168.1.130:8080

3个端口:
8080
8005 确认tomcat是否启动 可以直接看这个端口
8009

6.查看tomcat日志

[root@localhost ~]# tail -f /usr/local/tomcat/logs/catalina.out

 

posted @ 2020-07-29 10:17  Noleaf  阅读(110)  评论(0编辑  收藏  举报