The following is a test installation under centos6.9:
Install jenkins under docker:
Update yum source: yum -y update
Install docker: yum -y install docker-io
Start the docket service: service docker start
Self-starting: chkconfig docker on
Install jenkins: sudo docker pull jenkins
Manually specify the jenkins installation directory: cd /home && mkdir jenkins_home
Give the jenkins user the operating authority of the jenkins_home folder: sudo chown -R 1000 /home/jenkins_home
Start jenkins Docker on port 8080 (if it is already occupied, you can change to another port): sudo docker run -p 8080:8080 -p 50000:50000 -v /home/jenkins_home:/var/jenkins_home jenkins
To run in the background, use the following: sudo docker run -d -ti -p 8080:8080 -p 50000:50000 -v /home/jenkins_home:/var/jenkins_home jenkins
Visit 8080, enter the installation guide page, and find the initial password inside:
cat /home/jenkins_home/secrets/initialAdminPassword
**Direct installation: **
Install the java environment:
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie""http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz"
# tar xzf jdk-8u91-linux-x64.tar.gz
Of course, it is necessary to uninstall the installed java environment in advance:
rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'
Configure java environment variables:
vim /etc/profile
Add the following at the bottom of the profile file:
export JAVA_HOME=/opt/jdk1.8.0_91
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
Update the configuration file to make the configuration take effect:
source /etc/profile
Add jenkins yum source:
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
Install jenkins:
yum install jenkins
Start jenkins:
service jenkins start
Set jenkins to start automatically:
chkconfig jenkins on
If an error similar to the following occurs:
Starting Jenkins bash: /usr/bin/java: No such file or directory [FAILED]
It is because the default java path of jenkins is wrong, set as follows:
vi /etc/init.d/jenkins
Find the line /usr/bin/java, and add the following code below:
/opt/jdk1.8.0_91/bin/java
Then restart jenkins:
service jenkins start/stop/restart
If you still can't access it, try to close the linux firewall or allow port 8080 to pass through the firewall!
The full effect is as follows:
Recommended Posts