jenkins安装
jenkins的war包安装
以下war包的安装是直接使用war包内嵌的页面访问,也可以将war包放到tomcat的webapps下通过tomcat访问,在下面的tomcat步骤有补充说明
1、首先下载jenkins war包到相应的要安装的目录下(http://mirrors.jenkins.io/war-stable/latest/jenkins.war)
2、安装jdk,这里直接使用yum安装的,/etc/profile 下添加java的环境变量,source /etc/profile 重启 , jave -version查看版本
2、java -jar jenkins.war 运行war包;可以使用nohup命令 后台运行 nohup java -jar jenkins.war
3、http://http://ip:8080http://ip:8080 访问即可 (想要修改端口的话启动命令后面直接加参数 java -jar jenkins.war --httpPort=8081)
4、稍等一会出来如下页面,cat 上面的路径获取密码
5、根据提示可选择推荐安装或自定义安装,这里建议先选择推荐,后期需要的插件可在里面设置。
tomcat安装
1、下载安装包
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.zip
2、解压并放到相应目录
unzip apache-tomcat-9.0.24.zip #解压包
mv apache-tomcat-9.0.24 /usr/local/tomcat #重命名为tomcat
3、Tomcat设置变量
方法一:在/etc/profile中添加
方法二:定义在tomcat自带的启动和关闭脚本里/usr/local/tomcat/bin/startup.sh和shutdown.sh
在2个脚本中开头添加下面的内容:注意jdk是提前安装好的,并且注意自己实际的jdk的路径(下面有补充的jdk安装说明)
export JAVA_HOME=/usr/local/java/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 export TOMCAT_HOME=/usr/local/tomcat export CATALINA_HOME=/usr/local/tomcat export CLASS_PATH=$JAVA_HOME/bin/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tool.jar export PATH=$PATH:/usr/local/jjava/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/bin:/usr/local/tomcat/bin
4、启动tomcat
环境变量设置好后直接可通过脚本启动
[root@localhost bin]# sh 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/local/java/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
查看端口是否启动(默认端口8080)
[root@localhost bin]# netstat -antlp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2036/master tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 19664/zabbix_agentd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1597/sshd tcp 0 52 172.30.3.160:22 172.30.3.6:59429 ESTABLISHED 10838/sshd: root@pt tcp6 0 0 ::1:25 :::* LISTEN 2036/master tcp6 0 0 :::10050 :::* LISTEN 19664/zabbix_agentd tcp6 0 0 :::8009 :::* LISTEN 21846/java tcp6 0 0 :::8080 :::* LISTEN 21846/java tcp6 0 0 :::22 :::* LISTEN 1597/sshd
通过ip:8080访问
5、端口设置/usr/local/tomcat/conf/server.xml(jenkins的默认端口也是8080)
补充:上面在安装jenkins war包时说过,可以将war包直接放在tomcat的webapps下,通过直接访问tomcat来访问jenkins
在/usr/local/tomcat/webapps下wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war(这里我把tomcat端口设置成了8090,也可以不用)
关于jdk说明
上述使用的jdk都是yum安装,所以注意自己的安装路径
wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
#安装包安装可将包放在/usr/local下将包重名为jdk在/etc/profile中加入如下
export JAVA_HOME=/usr/local/jdk export JAVA_BIN=/usr/local/jdk/bin export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN PATH CLASSPATH
#yum安装默认的路径是/usr/lib/jvm中
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64 PATH=$PATH:$JAVA_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME CLASSPATH PATH
安装github
安装git
yum -y install git
初始化github
#下列的用户名和邮箱不需要一定存在,只要写就可以
[root@localhost webapps]# git config --global user.name "yang" [root@localhost webapps]# git config --global user.email "yang@abc.com"
查看git
[root@localhost webapps]# git version git version 1.8.3.1
生成密钥
[root@localhost webapps]# ssh-keygen -t rsa -C "yang@abc.com" #出现提示敲回车即可
#密钥路径,第一个是私钥,第二个是公钥
[root@localhost webapps]# cd ~/.ssh/ [root@localhost .ssh]# ls id_rsa id_rsa.pub
将公钥上传到github中,vim id_rsa.pub 将内容添加到图中位置
验证linux与github是否建立连接,输入下列命令
[root@localhost .ssh]# ssh git@github.com The authenticity of host 'github.com (52.74.223.119)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts. PTY allocation request failed on channel 0 Hi yyysir! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
安装maven
下载maven安装包到本地目录/usr/local
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
解压安装包并命名为maven
tar -zvxf apache-maven-3.3.9-bin.tar.gz mv apache-maven-3.3.9 maven
修改环境变量/etc/profile
export MAVEN_HOME=/usr/local/maven
export PATH=${MAVEN_HOME}/bin:$PATH
source /etc/profile 并检验安装
[root@localhost local]# mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: /usr/local/maven Java version: 1.8.0_222, vendor: Oracle Corporation Java home: /usr/local/java/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-123.el7.x86_64", arch: "amd64", family: "unix" [root@localhost local]#