Operating System Ubuntu

How to Install a Jenkins Automation Server on Ubuntu 26.04 LTS

Install Jenkins LTS on Ubuntu 26.04 LTS or 24.04 LTS from the project's apt repository, complete the first-run wizard and publish it through an Nginx reverse proxy.

Jenkins is an open-source automation server used to build, test and deploy software. At the end of this guide you will have the current Jenkins LTS release running as a systemd service on Ubuntu 26.04 LTS, unlocked and ready for its first job, and reachable under your own domain through an Nginx reverse proxy. The steps are identical on Ubuntu 24.04 LTS; the one difference is noted where it applies.

Requirements

  • A server running Ubuntu 26.04 LTS or 24.04 LTS and a user with sudo rights.
  • Memory and disk to match the workload. Jenkins starts with as little as 256 MB of RAM and 1 GB of disk, but the project recommends 4 GB of RAM or more and 50 GB of disk or more for a small team, because builds, workspaces and artifacts are what consume resources.
  • A domain name such as jenkins.example.com pointing to the server if you want the reverse proxy and HTTPS.

Step 1: Install Java

Jenkins is a Java application and the package does not pull in a Java runtime for you. Current Jenkins releases require Java 21 or later; Java 17 and older are no longer supported. Install OpenJDK 21 from the Ubuntu archive before Jenkins:

sudo apt update
sudo apt install fontconfig openjdk-21-jre

Check the result:

java -version

On Ubuntu 26.04 the distribution's default Java is OpenJDK 25, which Jenkins also supports, so a server that already has default-jre installed works too. On Ubuntu 24.04 the default is Java 21. If several Java versions are installed, select the one Jenkins should use with sudo update-alternatives --config java.

Step 2: Add the Jenkins repository

Ubuntu does not ship a current Jenkins package, so use the project's own apt repository. The debian-stable repository carries the LTS line, which gets a new baseline roughly every twelve weeks and is the right choice for a server other people depend on.

Download the repository signing key:

sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2026.key

Add the repository and restrict it to that key:

echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

The Jenkins project rotates its signing key from time to time and puts the year in the file name. If apt update later reports a signature error, look up the current key name in the Jenkins Linux installation guide and download it to the same path.

Step 3: Install and start Jenkins

sudo apt update
sudo apt install jenkins

The package creates a jenkins system user, installs a systemd unit, enables it at boot and starts Jenkins on port 8080. Its data directory, JENKINS_HOME, is /var/lib/jenkins. Check the service:

sudo systemctl status jenkins

Jenkins logs to the systemd journal, not to a file under /var/log. Follow the log while it starts:

sudo journalctl -u jenkins -f

Change the port or other service settings

Service settings are environment variables in the systemd unit. Do not edit the packaged unit file; create an override instead:

sudo systemctl edit jenkins

For example, if another program already uses port 8080, add:

[Service]
Environment="JENKINS_PORT=8081"

Save, then restart the service with sudo systemctl restart jenkins. Run systemctl cat jenkins to see every variable the unit understands, with comments.

Step 4: Unlock Jenkins and finish the setup wizard

If you use UFW and want to reach Jenkins directly for the initial setup, allow the port. Skip this if you go straight to the reverse proxy in step 5.

sudo ufw allow 8080/tcp

Open http://203.0.113.10:8080 in a browser, replacing the address with your server's. Jenkins asks for the initial administrator password, which it generated on first start. Print it:

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

Paste the value into the browser, then:

  1. Choose Install suggested plugins. It gives you Git, Pipeline and the other basics; more can be added later.
  2. Create the first admin user with a strong password. Do not continue as the built-in admin account.
  3. Confirm the Jenkins URL. If you plan to use a domain, you can correct it after step 5 under Manage Jenkins > System.

Step 5: Put Jenkins behind Nginx

Running Jenkins behind a reverse proxy lets you serve it on the standard ports with a TLS certificate. Install Nginx:

sudo apt install nginx

Create /etc/nginx/sites-available/jenkins with the following content. It is a trimmed version of the configuration in the Jenkins reverse-proxy documentation; the map block is needed for WebSocket connections.

upstream jenkins {
  keepalive 32;
  server 127.0.0.1:8080;
}

map $http_upgrade $connection_upgrade {
  default upgrade;
  '' '';
}

server {
  listen 80;
  server_name jenkins.example.com;

  access_log /var/log/nginx/jenkins.access.log;
  error_log  /var/log/nginx/jenkins.error.log;

  ignore_invalid_headers off;

  location / {
    sendfile off;
    proxy_pass         http://jenkins;
    proxy_redirect     default;
    proxy_http_version 1.1;

    proxy_set_header   Connection        $connection_upgrade;
    proxy_set_header   Upgrade           $http_upgrade;
    proxy_set_header   Host              $http_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;
    proxy_max_temp_file_size 0;

    client_max_body_size    10m;
    client_body_buffer_size 128k;

    proxy_connect_timeout   90;
    proxy_send_timeout      90;
    proxy_read_timeout      90;
    proxy_request_buffering off;
  }
}

Do not add a trailing slash to the proxy_pass value. Enable the site, test the configuration and reload Nginx:

sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Open the web ports and close direct access to Jenkins again:

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 8080/tcp

Add HTTPS with a Let's Encrypt certificate. Certbot edits the server block for you and sets up renewal:

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d jenkins.example.com

Finally, tell Jenkins its public address: go to Manage Jenkins > System, set Jenkins URL to https://jenkins.example.com/ and save. If Manage Jenkins shows a warning that the reverse proxy set-up is broken, the URL there does not match what the browser uses, or the X-Forwarded-Proto header is missing.

Maintenance

  • Updates. Jenkins is upgraded with the rest of the system: sudo apt update && sudo apt upgrade. Read the LTS upgrade guide on jenkins.io before moving to a new baseline, and update plugins under Manage Jenkins > Plugins afterwards. Security advisories are frequent, so do not let either fall behind.
  • Backups. Everything lives in /var/lib/jenkins: configuration, job definitions, credentials, plugins and build history. Back up that directory regularly, at least the configuration files, jobs, secrets and plugins.
  • Builds on the controller. For anything beyond experiments, run builds on separate agents and set the number of executors on the built-in node to 0. A build script running on the controller can read everything in JENKINS_HOME.

Frequently asked questions

Should I use the LTS or the weekly release?

LTS for servers that teams rely on: it changes baseline about every twelve weeks and receives backported fixes in between. The weekly line gets features first and suits test instances. To use it, replace debian-stable with debian in both the key URL and the repository line.

Jenkins does not start after a Java upgrade. What now?

Check sudo journalctl -u jenkins -e. Each Jenkins release supports a defined set of Java versions, and the service fails at start-up when the default java is outside that set. Select a supported version with update-alternatives, or point the service at a specific installation by setting JAVA_HOME in a systemctl edit jenkins override.

Can I serve Jenkins under a path such as /jenkins?

Yes, but Jenkins and the proxy must agree on the path. Set Environment="JENKINS_PREFIX=/jenkins" in a systemd override, restart Jenkins, and proxy the same path in Nginx.

Can I run Jenkins in Docker instead?

Yes. The project publishes an official jenkins/jenkins image with an lts tag, and the Jenkins documentation describes that route in its Docker installation chapter. The apt package is simpler when Jenkins is the main purpose of the server and you want it managed by systemd and apt.

Share story:

Continue reading other guides on How VPS.