添加yum repos,而後安裝html
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins
sudo yum install java
sudo service jenkins start/stop/restart sudo chkconfig jenkins on
/etc/init.d/jenkins
jenkins
, 若是你修改了user,則要修修改所屬者:/var/log/jenkins
,/var/lib/jenkins
,/var/cache/jenkins
/var/log/jenkins/jenkins.log
/etc/sysconfig/jenkins
firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload
firewall-cmd --list-all
Jenkins不支持在centos的默認的jdk上工做。若是以下所示,則須要remove:java
java -version java version "1.5.0" gij (GNU libgcj) version 4.4.6 20110731 (Red Hat 4.4.6-3)
爲了正確使用Jenkins:vim
yum remove java
而後能夠安裝openjdkcentos
yum install java-1.7.0-openjdk
正確以下:瀏覽器
java -version java version "1.7.0_79" OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14) OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
修改/etc/sysconfig/jenkins
:jvm
JENKINS_PORT="8080"
直接啓動:tcp
sudo service jenkins start
可是發現啓動失敗,因而須要配置java位置:ui
vi /etc/init.d/jenkins
在啓動加入本機的java:centos7
[root@iZ94xvn71eeZ ~]# vim /etc/init.d/jenkins # Set up environment accordingly to the configuration settings [ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } [ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME"; if [ "$1" = "stop" ]; then exit 0; else exit 1; fi; } # Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins. # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html candidates=" /etc/alternatives/java /usr/lib/jvm/java-1.8.0/bin/java /usr/lib/jvm/jre-1.8.0/bin/java /usr/lib/jvm/java-1.7.0/bin/java /usr/lib/jvm/jre-1.7.0/bin/java /usr/bin/java /usr/java/jdk1.7.0_80/bin/java "
上述最後一行是我添加的。插件
重啓,能夠正常運行了。
瀏覽器輸入ip和端口訪問,第一個頁面是正在啓動,啓動結束後會讓輸入一串密碼,而後進入插件安裝界面,選擇默認,這時候會報錯:
An error occurred during installation: Forbidden
解決辦法:
I "fixed it" by restarting Jenkins http://localhost:8080/restart。即重啓就能夠繼續了。