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-ipStep 2 — Update the System
For Amazon Linux 2 / RHEL / CentOS:
sudo yum update -yFor Ubuntu/Debian:
sudo apt update && sudo apt upgrade -yStep 3 — Install Java (Jenkins Requires Java 11 or 17)
Amazon Linux 2:
sudo amazon-linux-extras install java-openjdk11 -yUbuntu:
sudo apt install openjdk-17-jdk -yVerify Java installation:
java -versionStep 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 -yFor 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 -yStep 5 — Start & Enable Jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkinsYou should see active (running) in green.
Step 6 — Open Port 8080 in AWS Security Group
Go to your EC2 instance → Security Groups → Inbound Rules → Edit → 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>:8080Step 8 — Unlock Jenkins
Get the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPasswordCopy the password, paste it into the browser, and click Continue.
Step 9 — Complete Setup
- Click "Install Suggested Plugins" and wait for installation
- Create your Admin User (username, password, email)
- Set the Jenkins URL (use your EC2 public IP)
- 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 -fTroubleshooting 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.smallinstance