Inside Out

自分自身の備忘録。アウトプット用のブログです。

Linux初心者がさくらVPSでJenkinsを一から構築してみました(後編 Jenkins構築編)

Jenkins下準備

Jenkinsに取りかかる前に下準備としてJavaApacheを入れます。 Javaをインストールします。

yum list \*java-1\*
yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel

Apacheをインストールします。

yum -y install httpd

次にsudo vim /etc/httpd/conf/httpd.confを開き編集します。

#ServerTokens OS
ServerTokens Prod

#KeepAlive Off
KeepAlive On

#ServerAdmin root@localhost
ServerAdmin root@example.com

#ServerName www.example.com:80
ServerName www.example.com:80

#ServerSignature On
ServerSignature Off

TraceEnable Off

apacheを起動し、ついでにサーバ起動時に自動で起動するようにします。

sudo service httpd start #apache起動
sudo chkconfig httpd on #起動時設定

いよいよJenkinsをインストールします。

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
yum install jenkins

vim /etc/sysconfig/jenkinsでjenkinsの設定をします。Jenkinsのポートは初期だと8080です。被らない様に設定しましょう。

JENKINS_PORT="[任意のポート番号]"
JENKINS_ARGS="-prefix=/"

Apacheの設定をします。 vim /etc/httpd/conf/httpd.confで設定ファイルを開きます。末尾に下記を加えます。

<VirtualHost jenkins.[IPアドレス]:80>
    ServerAdmin root@localhost
    ServerName jenkins.[IPアドレス]
    <Location />
        ProxyPass http://localhost:[任意のポート番号]/
        ProxyPassReverse  http://localhost:[任意のポート番号]/
    </Location>
</VirtualHost>

ApacheとJenkinsを起動します。

sudo service jenkins start
sudo service httpd start

これでブラウザからアクセスできます。