🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
:-: 服务器列表(虚拟机统一采用CentOS7) |名称 |主机名 |安装的软件| |----|----|----| |代码托管服务器| gitlab-master |gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm| |持续集成服务器| jenkins-master |Jenkins-2.190.3、JDK1.8、Maven3.6.2、Git、SonarQube| |<mark>应用测试服务器</mark>| tomcat-master |JDK1.8、Tomcat8.5| [TOC] # 1. 安装Tomcat **1. 安装JDK1.8** ```shell --检查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_171 export PATH=$PATH:$JAVA_HOME/bin # source /etc/profile [root@app-server software]# java -version java 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/ ```shell wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz tar -xzf apache-tomcat-9.0.56.tar.gz -C /opt/install/ --启动Tomcat /opt/install/apache-tomcat-9.0.56/bin/startup.sh ``` **3. tomcat默认端口8080,开放8080端口** ```shell firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --reload ``` **4. 浏览器访问Tomcat:http://192.168.1.26:8080/** ![](https://img.kancloud.cn/15/8b/158b3b2161a3fa010a00131556b04005_1607x478.jpg) <br/> # 2. 配置Tomcat用户角色权限 默认情况下Tomcat是没有配置用户角色权限的,但是,后续Jenkins部署项目到Tomcat服务器,需要用到Tomcat的用户,所以需要配置Tomcat用户及权限。 <br/> **1. 添加角色与用户名** ```shell # vim %TOMCAT_HOME%/conf/tomcat-users.xml <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> ``` **2. 使用配置生效** ```shell # vim %TOMCAT_HOME%/webapps/manager/META-INF/context.xml <!-- 将下面注释掉即可 <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> ``` **3. 重启Tomcat** ```shell # bin/shutdown.sh # bin/startup.sh ``` **4. 使用用户名和密码登录Tomcat** ![](https://img.kancloud.cn/9a/51/9a51e42f158d02a2c11be6153975d3bb_1317x486.jpg) ![](https://img.kancloud.cn/5a/b3/5ab335b83e8f0b2b65b99c9bf35dfb4e_1555x530.jpg) <br/> 到这里Jenkins环境搭建完毕!