1. 安装Tomcat
安装JDK1.8
—检查CentOS7是否自带了JDK
rpm -qa | grep jdk
—如果自带了jdk则将其卸载,防止冲突
rpm -e jdk名
—安装jdk
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /opt/install/
—配置环境变量
# vim /etc/profile
export JAVA_HOME=/opt/install/jdk1.8.0_171export PATH=$PATH:$JAVA_HOME/bin# source /etc/profile
[root@app-server software]# java -versionjava version "1.8.0_171"Java(TM) SE Runtime Environment (build 1.8.0_171-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
2. 安装Tomcat
tomcat下载地址:https://tomcat.apache.org/
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gztar -xzf apache-tomcat-9.0.56.tar.gz -C /opt/install/
—启动Tomcat
/opt/install/apache-tomcat-9.0.56/bin/startup.sh
tomcat默认端口8080,开放8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
浏览器访问Tomcat:http://192.168.1.26:8080/
配置Tomcat用户角色权限
默认情况下Tomcat是没有配置用户角色权限的,但是,后续Jenkins部署项目到Tomcat服务器,需要用到Tomcat的用户,所以需要配置Tomcat用户及权限。
添加角色与用户名
<tomcat-users>
<role rolename="tomcat" />
<role rolename="role1" />
<role rolename="manager-script" />
<role rolename="manager-gui" />
<role rolename="manager-status" />
<role rolename="admin-gui" />
<role rolename="admin-script" />
<!-- 用户名:tomcat,密码:tomcat -->
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,tomcat,admin-gui,admin-script" />
</tomcat-users>
# vim %TOMCAT_HOME%/conf/tomcat-users.xml
使配置生效
<!-- 将下面注释掉即可
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
# vim %TOMCAT_HOME%/webapps/manager/META-INF/context.xml
重启Tomcat
# bin/shutdown.sh
# bin/startup.sh
使用用户名和密码登录Tomcat
到这里Jenkins环境搭建完毕!