Linux is, without question, the most common place I’ve deployed Jenkins — whether that’s Ubuntu, Debian, CentOS, or Amazon Linux running in the cloud. It’s stable, well-documented, and virtually every Jenkins plugin and integration assumes a Linux environment first. In this guide, I’ll walk through installing Jenkins on the most popular Linux distributions, plus the configuration steps you’ll want to take right after.
Why Linux Is the Standard Choice for Jenkins
Jenkins itself is a Java application, so technically it runs anywhere Java does. But in practice, Linux dominates production Jenkins deployments because of its resource efficiency, strong package management, container compatibility (Docker/Kubernetes), and the fact that most CI/CD tooling — Git, Docker, kubectl, Terraform, Ansible — is built with Linux as the primary target.
Jenkins Architecture Recap
Jenkins consists of a controller (handles scheduling, UI, and job configuration) and agents (execute actual build work). On Linux, it’s common to run the controller as a systemd service and connect additional Linux agents — physical, virtual, or containerized — for horizontal scaling.
Prerequisites
- A Linux server (Ubuntu 22.04/24.04, Debian 11/12, CentOS Stream, or Amazon Linux 2023 are all common choices)
- At least 2 CPU cores and 4GB RAM for a controller handling moderate load
- Java 17 or 21 (Jenkins requires a supported JDK version — check current requirements before installing)
Installing Jenkins on Ubuntu/Debian
Step 1: Install Java
sudo apt update
sudo apt install openjdk-17-jdk -y
java -version
Step 2: Add the Jenkins Repository
sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key \
-o /usr/share/keyrings/jenkins-keyring.asc
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
Step 3: Install Jenkins
sudo apt update
sudo apt install jenkins -y
Step 4: Start and Enable Jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins
Installing Jenkins on CentOS/RHEL/Rocky Linux
Step 1: Install Java
sudo dnf install java-17-openjdk -y
java -version
Step 2: Add the Jenkins 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-2023.key
Step 3: Install Jenkins
sudo dnf install jenkins -y
Step 4: Start and Enable Jenkins
sudo systemctl daemon-reload
sudo systemctl start jenkins
sudo systemctl enable jenkins
Step 5: Open the Firewall Port (if applicable)
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --reload
Installing Jenkins via Docker (Cross-Distro)
If you’d rather not manage a native install, Docker is a clean alternative on any Linux distro with Docker installed:
docker volume create jenkins_home
docker run -d \
--name jenkins \
-p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home \
jenkins/jenkins:lts-jdk17
This approach makes upgrades and rollbacks trivial — just change the image tag and restart the container, with jenkins_home persisting all your configuration and job data.
Step 5: Unlock Jenkins
Regardless of installation method, retrieve the initial admin password:
Native install:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Docker install:
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
Navigate to http://your-server-ip:8080, paste the password, and proceed through the setup wizard.
Step 6: Install Suggested Plugins and Create Admin User
Choose “Install suggested plugins” for a solid default set (Git, Pipeline, credentials management, etc.), then create your first admin account and confirm the Jenkins URL.
Step 7: Configure a Reverse Proxy (Recommended for Production)
Running Jenkins directly on port 8080 works for testing, but production setups typically sit behind Nginx or Apache with HTTPS. Example Nginx configuration:
server {
listen 443 ssl;
server_name jenkins.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/jenkins.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/jenkins.yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Update Jenkins’ configured root URL under Manage Jenkins > System to match this HTTPS address, ensuring webhooks and email links generate correctly.
Step 8: Install Additional Tools on Your Linux Agents
Depending on your project types, install the tools your pipelines will need directly on Linux agents:
sudo apt install git docker.io maven -y
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker jenkins
Adding the jenkins user to the docker group lets pipeline steps run Docker commands without requiring sudo.
Step 9: Backing Up Jenkins
Your entire Jenkins configuration and job history lives under /var/lib/jenkins (native install) or the jenkins_home Docker volume. Back this up regularly:
sudo tar -czf jenkins-backup-$(date +%F).tar.gz /var/lib/jenkins
Consider automating this with a scheduled job (ironically, you could even use Jenkins itself to back up Jenkins).
Step 10: Upgrading Jenkins
Native (Debian/Ubuntu):
sudo apt update
sudo apt upgrade jenkins -y
sudo systemctl restart jenkins
Docker:
docker pull jenkins/jenkins:lts-jdk17
docker stop jenkins
docker rm jenkins
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk17
Always check the Jenkins changelog before upgrading, especially for LTS-to-LTS jumps that skip several versions.
Real-World Deployment Scenario
A setup I’ve deployed for small-to-mid-size teams on a cloud VM:
- Jenkins runs as a systemd service on an Ubuntu 24.04 VM with 4 vCPUs and 8GB RAM.
- Nginx reverse-proxies HTTPS traffic with a Let’s Encrypt certificate.
- Two additional Linux agents (also on cloud VMs) handle actual build execution, keeping the controller free for orchestration only.
- Nightly backups of
/var/lib/jenkinssync to an S3 bucket via a scheduled job.
Installing Jenkins on Amazon Linux 2023
Cloud deployments on AWS often use Amazon Linux rather than Ubuntu or CentOS. The process is very similar to the RHEL-based approach:
sudo dnf install java-17-amazon-corretto -y
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 dnf install jenkins -y
sudo systemctl enable --now jenkins
If running on an EC2 instance, make sure the associated Security Group allows inbound traffic on port 8080 (or 443 if behind a load balancer/reverse proxy).
Running Jenkins Behind a Cloud Load Balancer
For production AWS deployments, it’s common to place an Application Load Balancer (ALB) in front of Jenkins, handling TLS termination with an ACM certificate rather than managing certificates manually via Certbot on the instance itself. Just remember to set Jenkins’ configured root URL under Manage Jenkins > System to the load balancer’s HTTPS address so generated links and webhook callback URLs resolve correctly.
Systemd Service Customization
Sometimes you need to tune Jenkins’ startup behavior — memory limits, custom Java options, or a different home directory. On systemd-based distros, these settings typically live in /etc/default/jenkins (Debian/Ubuntu) or /etc/sysconfig/jenkins (RHEL/CentOS):
JAVA_OPTS="-Xmx4g -Xms2g"
JENKINS_HOME="/data/jenkins_home"
After editing, reload systemd and restart the service:
sudo systemctl daemon-reload
sudo systemctl restart jenkins
Troubleshooting Common Installation Issues
- Jenkins fails to start: Check
sudo journalctl -u jenkins -ffor detailed error logs; often a Java version mismatch. - Port 8080 already in use: Either stop the conflicting service or change Jenkins’ port via
/etc/default/jenkins(Debian) or the--httpPortstartup argument. - “Waiting for Jenkins to start” hangs indefinitely: Check available disk space; Jenkins won’t start if the disk is full.
- Cannot access Jenkins from outside the server: Verify firewall/security group rules allow inbound traffic on the relevant port (8080 or 443 if behind a reverse proxy).
Security Best Practices
- Always run Jenkins behind HTTPS in production — never expose the raw HTTP port publicly.
- Restrict SSH and Jenkins admin access using firewall rules or a VPN.
- Enable Jenkins’ built-in security realm and matrix-based or role-based authorization immediately after install — don’t leave the initial setup wizard’s default “allow anyone to do anything” state active.
- Keep Jenkins and all plugins updated regularly to patch known CVEs.
Monitoring Jenkins Health on Linux
Once installed, keeping an eye on Jenkins’ own health matters just as much as the jobs it runs. The Monitoring Plugin exposes JVM metrics (heap usage, thread counts, garbage collection activity) directly in the Jenkins UI, while exporting metrics to Prometheus via the Prometheus Metrics Plugin lets you build proper alerting around controller resource exhaustion before it causes queued or failed builds.
FAQs
Q: Which Linux distribution is best for Jenkins? Ubuntu LTS and Debian are the most commonly documented and supported; CentOS/RHEL-based systems work equally well if that’s your organization’s standard.
Q: Should I use the native package install or Docker? Docker offers cleaner upgrades and portability; native installs integrate more simply with systemd and OS-level monitoring tools. Both are valid — pick based on your team’s existing operational practices.
Q: How much RAM does Jenkins actually need? For a small setup, 2-4GB is often enough; larger installations with many jobs, plugins, and concurrent builds may need 8GB+ for the controller alone, with agents scaled separately.
Q: Can I run Jenkins on Alpine Linux? Yes, and the official jenkins/jenkins Docker image is based on Alpine variants in some tags, though native package installs are less common on Alpine outside of Docker.
Summary
Installing Jenkins on Linux is a well-documented, repeatable process whether you choose a native package install via apt/dnf or a containerized Docker deployment. Once installed, securing it behind HTTPS, configuring backups, and adding dedicated agents for build execution will set you up for a stable, scalable CI/CD platform.
