Install jenkins on centos

Source: Internet
Author: User

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
  1. Export root@localhostlocal]#tar-zxvfjdk-7-linux-i586.tar.gz

1.3 modify Environment Variables

[Java] view plaincopy
  1. [Root @ localhostlocal] # vi/etc/profile

Add the following lines

[Java] view plaincopy
  1. ExportJAVA_HOME =/usr/local/jdk1.7.0
  2. ExportJRE_HOME =/usr/local/jdk1.7.0/jre
  3. ExportCLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
  4. ExportPATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH

1.4 run the command

[Java] view plaincopy
  1. [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
  1. [Root@localhostjdk1.7.0] # java-version
  2. Javaversion "1.7.0"
  3. Java (TM) SERuntimeEnvironment (build1.7.0-b147)
  4. JavaHotSpot (TM) ClientVM (build21.0-b17, mixedmode)
  5. Ng: 1.0pt ;}

2. Install maven

2.1 Download maven

[Java] view plaincopy
  1. [Root @ localhostlocal] # wgethttp: // response

2.2 decompress maven

[Java] view plaincopy
  1. 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
  1. MAVEN_HOME =/usr/local/apache-maven-3.3.9
  2. ExportMAVEN_HOME
  3. ExportPATH =$ {PATH }:$ {MAVEN_HOME}/bin

Make the modification take effect

[Java] view plaincopy
  1. [Root @ localhostlocal] # source/etc/profile

2.4 verify the installation result

[Java] view plaincopy
  1. [Root @ localhostlocal] # mvn-v
  2. ApacheMaven3.3.9 (bb52d8502b132ec0a5a3f4c09425c07478323dc5; 2015-11-10T08: 41: 47-08:00)
  3. Mavenhome:/usr/local/apache-maven-3.3.9
  4. Javaversion: 1.7.0, vendor: OracleCorporation
  5. Javahome:/usr/local/jdk1.7.0/jre
  6. Defaultlocale: en_US, platformencoding: UTF-8
  7. 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
  1. [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
  1. /Usr/local/jdk1.7.0/bin/java

[Java] view plaincopy
  1. [Root @ localhostjenkins] # vi/etc/sysconfig/jenkins
  2. Candidates ="
  3. /Etc/alternatives/java
  4. /Usr/lib/jvm/java-1.6.0/bin/java
  5. /Usr/lib/jvm/jre-1.6.0/bin/java
  6. /Usr/lib/jvm/java-1.7.0/bin/java
  7. /Usr/lib/jvm/jre-1.7.0/bin/java
  8. /Usr/lib/jvm/java-1.8.0/bin/java
  9. /Usr/lib/jvm/jre-1.8.0/bin/java
  10. /Usr/bin/java
  11. /Usr/local/jdk1.7.0/bin/java"

3.4 start jenkins

[Java] view plaincopy
  1. [Root @ localhostjenkins] # servicejenkinsstart
  2. 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
  1. -<Spanstyle = "font-family: Arial, Helvetica, sans-serif;"> AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport8080-jACCEPT </span>

[Java] view plaincopy
  1. [Root @ localhostjenkins] # vi/etc/sysconfig/iptables
  2. # Firewallconfigurationwrittenbysystem-config-firewall
  3. # Manualcustomizationofthisfileisnotrecommended.
  4. * Filter
  5. : INPUTACCEPT [0: 0]
  6. : FORWARDACCEPT [0: 0]
  7. : OUTPUTACCEPT [0: 0]
  8. -AINPUT-mstate -- stateESTABLISHED, RELATED-jACCEPT
  9. -AINPUT-picmp-jACCEPT
  10. -AINPUT-ilo-jACCEPT
  11. -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport22-jACCEPT
  12. -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport80-jACCEPT
  13. <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
  1. [Root @ localhostjenkins] # serviceiptablesrestart
  2. Iptables: SettingchainstopolicyACCEPT: filter [OK]
  3. Iptables: Flushingfirewallrules: [OK]
  4. Iptables: Unloadingmodules: [OK]
  5. 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
  1. [Root @ localhostsecrets] # viinitialAdminPassword
  2. 2aa80bb4a1ce4a269996b1b2ba6cefc1
3.8 view running logs

[Java] view plaincopy
  1. [Root @ localhostjenkins] # more/var/log/jenkins. log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.