Step by Step Installation of Jenkins on AWS EC2 Linux

Prerequisites:

1. Launch an Amazon EC2 Linux instance.
2. Open the default port 8080 in the inbound rules of your instance security group.

Installation:

Step 1: Create a jenkins-installation script file and give executable permissions to the file.

$ sudo vi jenkins-installation.sh

$ sudo chmod u+x jenkins-installation.sh

Step 2: Add the below commands in the script file.

Step 3: Run the below command

$ ./jenkins-installation.sh

Verify Installation:

1. Verify the Oracle JDK installation.

$ sudo java -version

2. Check whether the Jenkins path is set correctly or not

$ sudo ps -ef | grep -i jenkins

3. Check whether the default port 8080 is listening or not

$ sudo netstat -anlp | grep :8080

Note: If you get empty output, port 8080 is not listening else you will get output with Listen keyword.

4. Check whether the jenkins service is started or not

$ sudo systemctl status jenkins

5. Verify the OS level created Jenkins user

$ sudo id jenkins

6. Login to the newly created jenkins user

$ su -s /bin/bash jenkins

Access the Jenkins from portal:

  1. Open the browser and connect to jenkins via default port 8080
    http://<public-ip-address-of-ec2-instance>:8080

2. To unlock Jenkins fetch the administrator password from the above path. Execute the below command in ec2-instance.

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

3. Customize Jenkins. Select Install suggested plugins

4. Create first admin user. Fill the details and press Save and Continue.

5. Jenkins Dashboard

Conclusion:

This medium story explains the process of Jenkins Installation on the AWS EC2 Linux machine. Here we have installed Oracle JDK (as a prerequisite for Jenkins set-up), Jenkins and accessed the Jenkins tool in the browser. Now you can start exploring the Jenkins tool.

Senior DevOps and AWS Engineer. I am an AWS Certified Solution Architect Professional.