Linux初心者がさくらVPSでJenkinsを一から構築してみました(後編 Jenkins構築編)
Jenkins下準備
Jenkinsに取りかかる前に下準備としてJavaとApacheを入れます。 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
これでブラウザからアクセスできます。