Jenkins is the leading open-source automation server for CI/CD pipelines. This guide installs the latest LTS Jenkins on Ubuntu 24.04 LTS with Java 21 and configures it behind Nginx.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- Minimum 1 GB RAM (2 GB recommended)
- A user with sudo privileges
Step 1 – Install Java 21
Jenkins requires Java 11 or later. Install OpenJDK 21:
sudo apt update
sudo apt install openjdk-21-jdk -y
java -version
Step 2 – Add the Jenkins Repository
Import the Jenkins GPG key and add the repo:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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
Step 3 – Install Jenkins
Install from the official repo:
sudo apt update
sudo apt install jenkins -y
Step 4 – Start and Enable Jenkins
Start Jenkins and enable on boot:
sudo systemctl start jenkins
sudo systemctl enable jenkins
Step 5 – Open the Firewall
Allow Jenkins on port 8080:
sudo ufw allow 8080
sudo ufw allow OpenSSH
sudo ufw enable
Step 6 – Unlock Jenkins
Get the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Visit http://your_server_ip:8080, enter the password, and complete the setup wizard.
Step 7 – Configure Nginx Reverse Proxy
Create an Nginx proxy for Jenkins:
sudo nano /etc/nginx/sites-available/jenkins
Add:
server {
listen 80;
server_name jenkins.example.com;
location / {
proxy_pass http://localhost: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;
}
}
Enable and reload:
sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Conclusion
Jenkins is now running on Ubuntu 24.04 LTS. Install the recommended plugins and create your first pipeline to automate builds, tests, and deployments.