LoginSignup
1
1

More than 3 years have passed since last update.

EC2(AmazonLinux2)にJenkinsを構築する

Posted at

EC2 に Jenkins を構築したのでその作業のメモです。

鍵に権限を付与します。

$ chmod 600 KEY_NAME.pem

ログインします。

$ ssh -i KEY_NAME.pem ec2-user@{IP_ADDRES}

アップデートします。

$ sudo su -
$ yum -y update
$ yum -y upgrade

Nginx をインストールします。(必要な場合)

$ amazon-linux-extras install nginx1.12
$ yum -y install nginx
$ systemctl enable nginx.service
$ systemctl start nginx.service
$ systemctl status nginx.service

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

$ yum -y install docker
$ systemctl enable docker.service
$ systemctl start docker.service

マウントするディレクトリを作成します。

$ mkdir /home/jenkins_home
$ chown -R 1000:1000 /home/jenkins_home

Jenkins を起動します。

docker run \
  --name jenkins \
  --detach \
  --volume /home/jenkins_home:/var/jenkins_home \
  --publish 8080:8080 \
  --publish 50000:50000 \
  jenkins/jenkins:lts

Nginx の設定を追加します。(必要な場合)

nginx.conf
user root;
worker_processes  4;

events {
    worker_connections 1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;
}
jenkins.conf
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    location / {
        proxy_set_header Host $http_host;
        proxy_pass http://localhost:8080;
    }
}

Nginxを再起動します。

$ systemctl restart nginx.service

参考

Installing Jenkins

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1