Installing Jenkins on Amazon EC2
Tags: aws, devops, jenkins, ec2
Published: 2022-07-22 04:46:00

Prerequisite: You will need to have an Amazon account 

 Log into your amazon account and launch and EC2 instance. I chose the free tier here and launched the EC2 instance will be running Amazon Linux 2.  I have a detailed article on how to launch and EC2 machine here.

 Knowing that Jenkins is a Java based application, we need to make sure that we have Java also installed on our Amazon EC2 instance.  Only after that, we can proceed with the Jenkins installation. 
    Jenkins runs on port number 8080 so make sure you have the custom TCP Port 8080 open. 

![Security Group](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghf5co3zcji5o2xk47cc.png)
 I’m using MobaXterm to SSH into my EC2 instance, but you are free to use whatever tool you like. Start and SSH session, enter your remote host IP, user name and then under advance, load your private Key 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bkudimrq470xmh7gswr.png)
 After that, your login screen should be like the one bellow 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s6oj3465s56uhi4o1p2.png)

   Make sure that you have root access on your EC2 instance by entering sudo su -
 As mentioned above it is important to make sure that Java is installed on your EC2 instance prior to installing Jenkins  and for that, go to Jenkins download page and then select your linux flavor. 
Once there we are using Amazon Linux 2 so I will be selecting CentOS/Fedora/Red Hat as shown in the screen bellow https://pkg.jenkins.io/redhat-stable/


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pm7zoue3f6nv8kia4o65.png)

Proceed with the installation by following the instructions bellow.

First add the repository 

```
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

```

EPEL package is one of the requirement that doesn't unfortunately come with Amazon Linux 2 so we will need to install that by running the command bellow 

```
amazon-linux-extras install epel
```
After that, then install Java 

```
amazon-linux-extras install java-openjdk11
```
 Then proceed finally with Jenkins installation.

```
yum install jenkins
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qve8zxanbvk0l3fabov.png)


 Now you have successfully installed Jenkins on your EC2 instance. The next step will be to start Jenkins with the following command bellow and access it via your EC2 public IP on port 8080

```
service jenkins start
```
 Now navigate to the highlighted link in directory to retrieve the password and you should be good to go 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bczbwvw2bhubcgfaevog.png)

Now you can chose to launch your Jenkins instance with the suggested plugins or chose to install only the plugins you need 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmu6v0gvglvyrdysk1wk.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2f8t6qalpkta3pwjogd9.png)


 Lets keep in touch 

follow me on Twitter https://twitter.com/asksouley

 Great source for tech swags I found recently 

https://www.etsy.com/shop/GreenStoneStickers?ref=seller-platform-mcnav&section_id=37904360