26 August 2013

This post quick describes the Jenkins installation procedure on CentOS 6.4. This procedure is almost identical to suberbe one posted by ZAMMIT posted but I had to use openjdk instead of Java 1.5 that comes with CentOS 6.4.

Quickest option to run Jenkins…

$ cd $RUNDIR
$ wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
$ java -jar jenkins.war

Then connect to http://localhost:8080/jenkins


In order to have Jenkins start with the system and manage updates with yum, it is better to follow this installation procedure. So here we go! Read ZAMMIT"s post for more information.

  • Make sure your system is up to date
$ sudo yum update;
  • Install Jenkins rpm
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo;
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key;
$ yum install jenkins;
$ sudo yum install java-1.7.0-openjdk
  • Install Apache HTTPD
$ sudo yum install httpd
  • Add rule in iptables

Your /etc/sysconfig/iptables file should look like this

      1 # Firewall configuration written by system-config-firewall
      2 # Manual customization of this file is not recommended.
      3 *filter
      4 :INPUT ACCEPT [0:0]
      5 :FORWARD ACCEPT [0:0]
      6 :OUTPUT ACCEPT [0:0]
      7 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
      8 -A INPUT -p icmp -j ACCEPT
      9 -A INPUT -i lo -j ACCEPT
     10 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
     11 -A INPUT -j REJECT --reject-with icmp-host-prohibited
     12 -A FORWARD -j REJECT --reject-with icmp-host-prohibited
     13 COMMIT

We need to install a new rule similar to the one at line 10 but for port 80. This sequence will to the trick! Compare your file with the previous listing and adjust the line number if needed before running it.

$ sudo iptables-save > /etc/sysconfig/iptables.prejenkins-$(date '+%Y%m%d-%H%M%S')
$ sudo sed -i '11i-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables
$ sudo service iptables restart

In case of problem, revert to the backed-up file, here the /etc/sysconfig/iptables.prejenkins- with the following command.

$ sudo iptables-restore < /etc/sysconfig/iptables.prejenkins-<timestamp>
  • Make sure AJP module is enabled in HTTPD configuration file.
$ grep ajp /etc/httpd/conf/httpd.conf

It should display a line like this

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
  • Create a virtual host for Jenkins
$ JENKINS_FQDN="jenkins.my.fqdn"
$ sudo cat << EOT >> /etc/httpd/conf.d/vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
        ServerName $JENKINS_FQDN
        ProxyRequests Off
        ProxyPreserveHost On
        ProxyPass / ajp://
        ProxyPassReverse / ajp://
        ProxyPassReverseCookiePath / /

Yes, you must change jenkins.my.fqdn with your server name!

  • Start the services!
$ sudo service httpd start
$ service jenkins start

Then connect to http://localhost:8080/jenkins and it should work smile

  • Verify that both services will be started automatically with the server
$ chkconfig httpd --list
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
$ chkconfig jenkins --list
jenkins         0:off   1:off   2:off   3:on    4:off   5:on    6:off

bangbang httpd will is turned off! Let"s enable it with

$ chkconfig httpd on
[root@jenkins sysconfig]# chkconfig httpd --list
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

clap Job"s done!

blog comments powered by Disqus