Install jenkins on centos
1. Install JDK 7
1.1 download JDK7
You may not be able to directly use wget for download. You can use thunder for download.
Http://download.oracle.com/otn-pub/Java/jdk/7/jdk-7-linux-i586.tar.gz
Copy to directory/usr/local
1.2 unzip the installation package
[Java] view plaincopy
- Export root@localhostlocal]#tar-zxvfjdk-7-linux-i586.tar.gz
1.3 modify Environment Variables
[Java] view plaincopy
- [Root @ localhostlocal] # vi/etc/profile
Add the following lines
[Java] view plaincopy
- ExportJAVA_HOME =/usr/local/jdk1.7.0
- ExportJRE_HOME =/usr/local/jdk1.7.0/jre
- ExportCLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
- ExportPATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH
1.4 run the command
[Java] view plaincopy
- [Root @ bogonopt] # source/etc/profile
In this way, the modification of environment variables takes effect.
1.5 verify the JDK installation result
[Java] view plaincopy
- [Root@localhostjdk1.7.0] # java-version
- Javaversion "1.7.0"
- Java (TM) SERuntimeEnvironment (build1.7.0-b147)
- JavaHotSpot (TM) ClientVM (build21.0-b17, mixedmode)
- Ng: 1.0pt ;}
2. Install maven
2.1 Download maven
[Java] view plaincopy
- [Root @ localhostlocal] # wgethttp: // response
2.2 decompress maven
[Java] view plaincopy
- Export root@localhostlocal]#tar-zxvfapache-maven-3.3.9-bin.tar.gz
2.3 configure the maven installation path
Modify the file/etc/profile and add the following three lines
[Java] view plaincopy
- MAVEN_HOME =/usr/local/apache-maven-3.3.9
- ExportMAVEN_HOME
- ExportPATH =$ {PATH }:$ {MAVEN_HOME}/bin
Make the modification take effect
[Java] view plaincopy
- [Root @ localhostlocal] # source/etc/profile
2.4 verify the installation result
[Java] view plaincopy
- [Root @ localhostlocal] # mvn-v
- ApacheMaven3.3.9 (bb52d8502b132ec0a5a3f4c09425c07478323dc5; 2015-11-10T08: 41: 47-08:00)
- Mavenhome:/usr/local/apache-maven-3.3.9
- Javaversion: 1.7.0, vendor: OracleCorporation
- Javahome:/usr/local/jdk1.7.0/jre
- Defaultlocale: en_US, platformencoding: UTF-8
- OSname: "linux", version: "2.6.32-431. el6.i686", arch: "i386", family: "unix"
3. Install Jenkins
3.1 download jenkins
Http: // 211.162.52.227/files/4054000003480AF6/files
Copy the installation package to the/usr/local directory.
3. 2. Install jenkins
[Java] view plaincopy
- [Root @ localhostlocal] # rpm-ivhjenkins-2.7.3-1.1.noarch.rpm
The jenkins installation directory is/usr/lib/jenkins, which contains a WAR package jenkins. war
3. Modify the jenkins configuration file
Add the following line
[Java] view plaincopy
- /Usr/local/jdk1.7.0/bin/java
[Java] view plaincopy
- [Root @ localhostjenkins] # vi/etc/sysconfig/jenkins
- Candidates ="
- /Etc/alternatives/java
- /Usr/lib/jvm/java-1.6.0/bin/java
- /Usr/lib/jvm/jre-1.6.0/bin/java
- /Usr/lib/jvm/java-1.7.0/bin/java
- /Usr/lib/jvm/jre-1.7.0/bin/java
- /Usr/lib/jvm/java-1.8.0/bin/java
- /Usr/lib/jvm/jre-1.8.0/bin/java
- /Usr/bin/java
- /Usr/local/jdk1.7.0/bin/java"
3.4 start jenkins
[Java] view plaincopy
- [Root @ localhostjenkins] # servicejenkinsstart
- StartingJenkins [OK]
3.5 open port 8080
The default port number of jenkins is 8080. The firewall must open this port for external access.
Add the following line
[Java] view plaincopy
- -<Spanstyle = "font-family: Arial, Helvetica, sans-serif;"> AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport8080-jACCEPT </span>
[Java] view plaincopy
- [Root @ localhostjenkins] # vi/etc/sysconfig/iptables
- # Firewallconfigurationwrittenbysystem-config-firewall
- # Manualcustomizationofthisfileisnotrecommended.
- * Filter
- : INPUTACCEPT [0: 0]
- : FORWARDACCEPT [0: 0]
- : OUTPUTACCEPT [0: 0]
- -AINPUT-mstate -- stateESTABLISHED, RELATED-jACCEPT
- -AINPUT-picmp-jACCEPT
- -AINPUT-ilo-jACCEPT
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport22-jACCEPT
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport80-jACCEPT
- <Precode_snippet_id = "1876506" snippet_file_name = "canonical" name = "code" class = "java">-<spanstyle = "font-family: Arial, Helvetica, sans-serif; "> AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport8080-jACCEPT </span>
-A input-jREJECT -- reject-with icmp-host-prohibited-a forward-jREJECT -- reject-with icmp-host-prohibited
3.6 restart the Firewall
[Java] view plaincopy
- [Root @ localhostjenkins] # serviceiptablesrestart
- Iptables: SettingchainstopolicyACCEPT: filter [OK]
- Iptables: Flushingfirewallrules: [OK]
- Iptables: Unloadingmodules: [OK]
- Iptables: Applyingfirewallrules: [OK]
3.7 access jenkins through a browser
Http: // 192.168.1.105: 8080
Go to the/var/lib/jenkins/secrets directory
View Password
[Java] view plaincopy
- [Root @ localhostsecrets] # viinitialAdminPassword
- 2aa80bb4a1ce4a269996b1b2ba6cefc1
3.8 view running logs
[Java] view plaincopy
- [Root @ localhostjenkins] # more/var/log/jenkins. log