Prerequisites

Before you begin, make sure you have:

  • An AWS EC2 instance running (Amazon Linux 2, Ubuntu, or RHEL)
  • SSH access to your instance
  • Security Group with port 8080 open (Jenkins default port)
  • At least t2.micro (1GB RAM minimum, t2.small recommended)

Step 1 — Connect to Your EC2 Instance

ssh -i "your-key.pem" ec2-user@your-ec2-public-ip

Step 2 — Update the System

For Amazon Linux 2 / RHEL / CentOS:

sudo yum update -y

For Ubuntu/Debian:

sudo apt update && sudo apt upgrade -y

Step 3 — Install Java (Jenkins Requires Java 11 or 17)

Amazon Linux 2:

sudo amazon-linux-extras install java-openjdk11 -y

Ubuntu:

sudo apt install openjdk-17-jdk -y

Verify Java installation:

java -version

Step 4 — Add Jenkins Repository & Install

For Amazon Linux 2 / RHEL / CentOS:

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-2023.key
sudo yum install jenkins -y

For Ubuntu/Debian:

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | \
    sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian-stable binary/ | \
    sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt update
sudo apt install jenkins -y

Step 5 — Start & Enable Jenkins

sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins

You should see active (running) in green.

Step 6 — Open Port 8080 in AWS Security Group

Go to your EC2 instance → Security GroupsInbound RulesEdit → Add rule:

Type Protocol Port Source Custom TCP TCP 8080 0.0.0.0/0

Step 7 — Access Jenkins in Browser

Open your browser and navigate to:

http://<your-ec2-public-ip>:8080

Step 8 — Unlock Jenkins

Get the initial admin password:

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

Copy the password, paste it into the browser, and click Continue.

Step 9 — Complete Setup

  1. Click "Install Suggested Plugins" and wait for installation
  2. Create your Admin User (username, password, email)
  3. Set the Jenkins URL (use your EC2 public IP)
  4. Click "Start using Jenkins" 🎉

Useful Jenkins Commands

# Start Jenkins
sudo systemctl start jenkins
# Stop Jenkins
sudo systemctl stop jenkins
# Restart Jenkins
sudo systemctl restart jenkins
# Check Jenkins logs
sudo journalctl -u jenkins -f

Troubleshooting Tips

  • Jenkins not starting? Check Java is installed: java -version
  • Can't access port 8080? Verify Security Group inbound rules
  • Forgot admin password? Re-run: sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  • Low memory issues? Upgrade to at least t2.small instance