Jenkins を Tomcat へ複数インストール

Jenkins をプロジェクト単位で複数インストールするときのメモ

AWS EC2 の Amazon Linux AMI(2012.09)

最新へ

yum -y update
shutdown -r now

Apache httpd(2.2) インストール

yum -y install httpd

Apache tomcat(6.0)インストール

yum -y install tomcat6

tomcat6 の i18n 設定
vi /etc/tomcat6/server.xml

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

へ変更

自動起動設定

chkconfig --level 345 httpd on
chkconfig --level 345 tomcat6 on
shutdown -r now

jenkins の作業ディレクトリ(JENKINS_HOME)作成

mkdir /var/lib/jenkins
mkdir /var/lib/jenkins/prj1
mkdir /var/lib/jenkins/prj2
chown -Rf tomcat:tomcat /var/lib/jenkins

各 jenkins に JENKINS_HOME を設定

vi /etc/tomcat6/Catalina/localhost/prj1.xml

<?xml version='1.0' encoding='utf-8'?>
<Context>

    <Environment name="JENKINS_HOME" type="java.lang.String" override="false" value="/var/lib/jenkins/prj1" />

</Context>

vi /etc/tomcat6/Catalina/localhost/prj2.xml

<?xml version='1.0' encoding='utf-8'?>
<Context>

    <Environment name="JENKINS_HOME" type="java.lang.String" override="false" value="/var/lib/jenkins/prj2" />

</Context>

tomcat6 に jenkins を配備

curl --location http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war > /usr/share/tomcat6/webapps/prj1.war
curl --location http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war > /usr/share/tomcat6/webapps/prj2.war

設定を反映

service tomcat6 restart

httpd にリバースプロキシ設定

ProxyPass /prj1 ajp://127.0.0.1:8009/prj1
ProxyPassReverse /prj1 ajp://127.0.0.1:8009/prj1

ProxyPass /prj2 ajp://127.0.0.1:8009/prj2
ProxyPassReverse /prj2 ajp://127.0.0.1:8009/prj2
This entry was posted in jenkins, Tomcat. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>