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

centos部署jenkins

时间:2017-12-31 10:48:31      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:font   配置管理   生效   strong   classpath   rpo   XML   acl   iptable   

1. 实验环境:

 
操作系统: CentOS Linux release 7.2.1511 (Core)
软件版本: jdk-8u60-linux-x64    apache-tomcat-9.0.0.M17    jenkins-2.44
实验条件: 关闭防火墙,iptables 开启对主机 80 / 8080 端口的访问
 
systemctl stop firewalld  
iptables -A INPUT -p tcp -s 0/0 --dport 80 -j ACCEPT  
iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT  
iptables -A INPUT -p tcp -s 0/0 --dport 8080 -j ACCEPT  
iptables -A OUTPUT -p tcp --sport 8080 -m state --state ESTABLISHED -j ACCEPT  
iptables-save  

2. 安装 Java 环境

a. 安装包下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html (请根据实际情况选择对应的安装包)

本文使用的安装包是:jdk-8u60-linux-x64.tar.gz
wget http://download.Oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz (请替换成安装包下载地址里面具体安装包的对应链接)  
tar xzvf jdk-8u60-linux-x64.tar.gz -C /usr/local/   
cd /usr/local/  
ln -sv jdk1.8.0_60 jdk  

 

b. 配置环境变量:

vim /etc/profile.d/jdk.sh  
--------------------------------------------------->  
JAVA_HOME=/usr/local/jdk  
PATH=$JAVA_HOME/bin:$PATH  
export JAVA_HOME PATH  
<---------------------------------------------------  
. /etc/profile.d/jdk.sh //重读此文件,让变量生效  

 

3. 查看JAVA是否安装成功:

[root@localhost local]# java -version  
java version "1.8.0_60"  
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)  
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)  

3. 安装 Tomcat

 
a. 安装包下载地址:http://tomcat.apache.org/download-90.cgi  (请根据实际情况选择对应的安装包)
本文使用的安装包是:9.0.0.M17 > Binary Distributions > Core > tar.gz 
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M17/bin/apache-tomcat-9.0.0.M17.tar.gz  
tar xzvf apache-tomcat-9.0.0.M17.tar.gz -C /usr/local/  
cd /usr/local/  
ln -sv apache-tomcat-9.0.0.M17 tomcat  

 

b. 配置环境变量:
 
vim /etc/profile.d/tomcat.sh  
--------------------------------------------------->  
CATALINA_BASE=/usr/local/tomcat  
PATH=$CATALINA_BASE/bin:$PATH  
JENKINS_HOME=$CATALINA_BASE/webapps/jenkins  
export PATH CATALINA_BASE JENKINS_HOME  
<---------------------------------------------------  
. /etc/profile.d/tomcat.sh  

c. 查看tomcat是否安装成功:

[root@localhost local]# catalina.sh version  
Using CATALINA_BASE:   /usr/local/tomcat  
Using CATALINA_HOME:   /usr/local/tomcat  
Using CATALINA_TMPDIR: /usr/local/tomcat/temp  
Using JRE_HOME:        /usr/local/jdk  
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar  
Server version: Apache Tomcat/9.0.0.M17  
Server built:   Jan 10 2017 20:59:20 UTC  
Server number:  9.0.0.0  
OS Name:        Linux  
OS Version:     3.10.0-327.28.3.el7.x86_64  
Architecture:   amd64  
JVM Version:    1.8.0_60-b27  
JVM Vendor:     Oracle Corporation  

 

 

4. 配置 Tomcat

 a. 配置server.xml:
vim /usr/local/tomcat/conf/server.xml  
---------------------------------------------------------->  
<Connector port="80" protocol="HTTP/1.1" //默认端口为8080,改为80  
connectionTimeout="20000"  
redirectPort="8443" />  

 

b. tomcat有 manager-gui 的管理页面,想要使用必须配置管理用户,不使用可以跳过此步。配置tomcat-users.xml:

vim /usr/local/tomcat/conf/tomcat-users.xml  
------------------------------------------------------------------------------->  
<role rolename="manager-gui"/> //指定用户可以使用的接口为manager-gui  
<user username="tomcat" password="tomcat" roles="manager-gui"/> //用户名和密码为tomcat,在manager-gui接口使用  

 

5. 安装 Jenkins 到 Tomcat

 

a. 安装包下载地址:http://mirrors.jenkins-ci.org/war/latest/jenkins.war

wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war  
mkdir /usr/local/tomcat/webapps/jenkins  
cp jenkins.war /usr/local/tomcat/webapps/jenkins  
cd /usr/local/tomcat/webapps/jenkins  
jar -xvf jenkins.war  

 

b. 安装完成,现在可以开启 Tomcat 来使用 jenkins 了:

[root@localhost jenkins]# catalina.sh start  
Using CATALINA_BASE: /usr/local/tomcat  
Using CATALINA_HOME: /usr/local/tomcat  
Using CATALINA_TMPDIR: /usr/local/tomcat/temp  
Using JRE_HOME: /usr/local/jdk  
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar  

 

c. 在 Client 上打开浏览器,访问 http://172.0.0.1/jenkins 

 

参考文献:
http://www.linuxidc.com/Linux/2015-08/122234.htm
https://wiki.jenkins-ci.org/display/JENKINS/Tomcat
http://blog.sina.com.cn/s/blog_61df320b01019z4c.html
http://www.server110.com/linux/201308/740.html

centos部署jenkins

标签:font   配置管理   生效   strong   classpath   rpo   XML   acl   iptable   

原文地址:https://www.cnblogs.com/EWWE/p/8151922.html

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