Running Jenkins in Tomcat6 on CentOS 6.5

A quick note on how to make Jenkins run on a CentOS server and show its web face in Tomcat6.

First add the repositories we need and install jenkins itself:

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 -y

Then install tomcat6:

yum install tomcat6 -y

On a clean system it pulls 100+ megabytes of dependencies.

Add Tomcat and jenkins to autostart:

chkconfig jenkins on  
chkconfig tomcat6 on

A couple of Tomcat configs need editing. They live in /usr/share/tomcat6/conf

cd /usr/share/tomcat6/conf

Edit the contexts file:

vim context.xml

Add the following line to it:

<Environment name="JENKINS_HOME" value="/usr/lib/jenkins/" type="java.lang.String"/>

Edit the main config:

vim tomcat6.conf

Set the extra parameters for catalina in it, namely JENKINS_HOME:

CATALINA_OPTS="-DJENKINS_HOME=/usr/lib/jenkins/ -Xmx512m"

Create a user to access the Jenkins interface:

vim tomcat-users.xml

Add the following to the file:

<role rolename="admin"/>
<user username="jenkins-admin" password="secret" roles="admin"/>

Restart tomcat so that the changes take effect:

/etc/init.d/tomcat6 restart

The Jenkins web interface will be available at http://localhost:8080/

Screenshot from 2015-10-09 10:58:22

Categories:

Updated: