Installing Jenkins on Rocky Linux 9
Jenkins is a popular open-source automation server for continuous integration and continuous deployment (CI/CD), letting teams build, test, and deploy software with a large ecosystem of plugins. This guide installs Jenkins on Rocky Linux 9, secures the web interface behind Nginx with a Let's Encrypt SSL certificate, tunes system limits for heavier workloads, and sets up automated backups. By the end, you'll have Jenkins running securely over HTTPS with a test job verified through both the dashboard and the Jenkins CLI.
Before you begin, you need access to a Rocky Linux 9 instance as a non-root sudo user, and a domain A record pointing to the instance's IP address (for example, example.com) configured with your DNS provider.
Install Java
Jenkins requires the Java Development Kit (JDK) to run.
Update the package index:
$ sudo dnf update -yInstall OpenJDK 21 (or the latest version from the OpenJDK releases page):
$ sudo dnf install -y java-21-openjdkCheck for and switch away from an older default Java version:
$ sudo alternatives --config javaIf multiple Java versions are installed, you'll see output like:
There are two programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.442.b06-2.el9.x86_64/jre/bin/java) 2 java-21-openjdk.x86_64 (/usr/lib/jvm/java-21-openjdk-21.0.6.0.7-1.el9.x86_64/bin/java) Enter to keep the current selection[+], or type selection number:Type
2to select OpenJDK 21.Verify the installation:
$ java -versionOutput:
openjdk 21.0.6 2025-01-21 LTS OpenJDK Runtime Environment (Red_Hat-21.0.6.0.7-1) (build 21.0.6+7-LTS) OpenJDK 64-Bit Server VM (Red_Hat-21.0.6.0.7-1) (build 21.0.6+7-LTS, mixed mode, sharing)
Install Jenkins
Add the latest stable Jenkins repository to your DNF sources:
$ sudo wget https://pkg.jenkins.io/redhat-stable/jenkins.repo -O /etc/yum.repos.d/jenkins.repoImport the GPG key for your version:
$ sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.keyInstall Jenkins:
$ sudo dnf install -y jenkinsStart the Jenkins service:
$ sudo systemctl start jenkinsEnable Jenkins to start on boot:
$ sudo systemctl enable jenkinsCheck its status:
$ sudo systemctl status jenkinsOutput:
โ jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled) Active: active (running) since Sun 2025-02-23 10:45:53 UTC; 21s ago Main PID: 5166 (java) Tasks: 44 (limit: 11059) Memory: 407.4M CPU: 12.385s CGroup: /system.slice/jenkins.service โโ5166 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 Feb 23 10:45:47 test-server jenkins[5166]: 69638179145e4a3fa6826e5fe6c427da Feb 23 10:45:47 test-server jenkins[5166]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword Feb 23 10:45:47 test-server jenkins[5166]: ************************************************************* Feb 23 10:45:47 test-server jenkins[5166]: ************************************************************* Feb 23 10:45:47 test-server jenkins[5166]: ************************************************************* Feb 23 10:45:53 test-server jenkins[5166]: 2025-02-23 10:45:53.349+0000 [id = 32]INFO jenkins.InitReactorRunner$1#onAttained: Completed initiali> Feb 23 10:45:53 test-server jenkins[5166]: 2025-02-23 10:45:53.367+0000 [id = 24]INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up an> Feb 23 10:45:53 test-server systemd[1]: Started Jenkins Continuous Integration Server. Feb 23 10:45:55 test-server jenkins[5166]: 2025-02-23 10:45:55.036+0000 [id = 47]INFO h.m.DownloadService$Downloadable#load: Obtained the update> Feb 23 10:45:55 test-server jenkins[5166]: 2025-02-23 10:45:55.038+0000 [id = 47]INFO hudson.util.Retrier#start: Performed the action check upda>
Access the Jenkins Web Interface
Allow the default Jenkins port 8080 through the firewall:
$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcpReload the firewall:
$ sudo firewall-cmd --reloadGet the initial administrator password:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPasswordCopy the output.
Open Jenkins in a browser using your domain name on port 8080:
http://example.com:8080Paste the password into the Administrator Password field and click Continue.
Select Install suggested Plugins to install the recommended Jenkins plugins.
Fill in the details for your first Admin User and click Save and Continue.
Confirm the Jenkins URL, which should match your domain name, then click Save and Finish.
Click Start using Jenkins to open the Jenkins dashboard.
Secure Jenkins with Let's Encrypt SSL Certificates
Install the Nginx web server:
$ sudo dnf install nginx -yInstall Certbot and its Nginx plugin:
$ sudo dnf install -y certbot python3-certbot-nginxAllow HTTP traffic:
$ sudo firewall-cmd --permanent --add-service=httpAllow HTTPS traffic:
$ sudo firewall-cmd --permanent --add-service=httpsReload the firewall:
$ sudo firewall-cmd --reloadRequest an SSL certificate:
$ sudo certbot certonly --standalone -d example.comCertbot will prompt you in sequence: for an email address; to accept its terms of service; and, optionally, whether to share your email with the Electronic Frontier Foundation (you can decline with
N). Your domain now has a valid certificate for TLS encryption.Enable and start Nginx:
$ sudo systemctl enable --now nginxAllow Jenkins to communicate over the network via SELinux:
$ sudo setsebool -P httpd_can_network_connect 1Open the Nginx configuration file:
$ sudo nano /etc/nginx/conf.d/jenkins.confAdd the following configuration:
server { listen 80; server_name example.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.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; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; # WebSocket Support for Jenkins proxy_http_version 1.1; proxy_request_buffering off; proxy_buffering off; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } }Save and close the file.
Note: don't add
https://or a trailing/to your domain in theserver_namedirective.Test the Nginx configuration:
$ sudo nginx -tOutput:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successfulRestart Nginx:
$ sudo systemctl restart nginxOpen your browser and go to:
https://example.comJenkins should now be accessible over HTTPS.
Update the Jenkins URL to HTTPS. In the dashboard, go to Manage Jenkins > System, find the Jenkins Location section, change the URL from
http://example.com:8080tohttps://example.com/, and click Save.Restart Jenkins to apply the new URL:
$ sudo systemctl restart jenkins
Optimize Jenkins Performance
Configure System Limits
Open the limits configuration file:
$ sudo nano /etc/security/limits.confAdd the following lines before the
#End of filecomment to raise the maximum open files Jenkins can use:jenkins soft nofile 65536 jenkins hard nofile 65536Save and close the file.
Restart Jenkins to apply the change:
$ sudo systemctl restart jenkinsVerify the new limit is applied:
$ cat /proc/$(pgrep -u jenkins java)/limits | grep "open files"Output:
Max open files 524288 524288 files
Implement a Backup Strategy
Create a folder to store backups:
$ mkdir ~/jenkins_backupCopy Jenkins data (configuration files, jobs, and user data) to the backup folder:
$ sudo cp -r /var/lib/jenkins ~/jenkins_backup/Edit your cron jobs to schedule automatic daily backups:
$ crontab -eAdd the following line to run the backup every day at midnight:
0 0 * * * sudo cp -r /var/lib/jenkins ~/jenkins_backup/Save and exit.
Confirm the cron job was saved:
$ crontab -lCheck the cron service status:
$ sudo systemctl status crondOutput:
โ crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; preset: enabled) Active: active (running) since Sun 2025-02-23 10:43:02 UTC; 1h 18min ago Main PID: 1348 (crond) Tasks: 1 (limit: 11059) Memory: 1.2M CPU: 66ms CGroup: /system.slice/crond.service โโ1348 /usr/sbin/crond -n Feb 23 10:43:02 test-server crond[1348]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 33% if used.) Feb 23 10:43:02 test-server crond[1348]: (CRON) INFO (running with inotify support) Feb 23 11:01:01 test-server CROND[5547]: (root) CMD (run-parts /etc/cron.hourly) Feb 23 11:01:01 test-server run-parts[5550]: (/etc/cron.hourly) starting 0anacron Feb 23 11:01:01 test-server run-parts[5556]: (/etc/cron.hourly) finished 0anacron Feb 23 11:01:01 test-server CROND[5546]: (root) CMDEND (run-parts /etc/cron.hourly) Feb 23 12:01:01 test-server CROND[9621]: (root) CMD (run-parts /etc/cron.hourly) Feb 23 12:01:01 test-server run-parts[9624]: (/etc/cron.hourly) starting 0anacron Feb 23 12:01:01 test-server run-parts[9630]: (/etc/cron.hourly) finished 0anacron Feb 23 12:01:01 test-server CROND[9620]: (root) CMDEND (run-parts /etc/cron.hourly)If the status is active, the backup job will run as scheduled.
Access and Test Jenkins
Test via the Dashboard
- Open Jenkins in your browser and sign in to the dashboard.
- Click New Item, enter a job name (e.g.,
TestJob), select Freestyle Project, and click OK. - Under Build Step, select Add build step > Execute shell and enter:
$ echo "Hello, Jenkins!" - Click Save, then Build Now to run the job.
- Open the build (e.g.,
#1) and click Console Output to view the logs - if you see the echoed message, the setup was successful.
Test Using the Command Line
From the dashboard, click your username, then go to the Security tab.
Under API Token, click Add New Token, name it, click Generate, and save the token securely.
Download the Jenkins CLI jar file:
$ wget https://example.com/jnlpJars/jenkins-cli.jarReplace
example.comwith your actual domain name.Move the jar file to a convenient location:
$ mv jenkins-cli.jar ~/jenkins-cli.jarCheck the connection:
$ java -jar ~/jenkins-cli.jar -s https://example.com/ -auth your_username:your_api_token versionReplace
your_usernameandyour_api_tokenwith your Jenkins username and API token.Output:
2.492.1Trigger the test job:
$ java -jar ~/jenkins-cli.jar -s https://example.com/ -auth your_username:your_api_token build TestJobView the build console output:
$ java -jar ~/jenkins-cli.jar -s https://example.com/ -auth your_username:your_api_token console TestJobOutput:
Running as SYSTEM Building in workspace /var/lib/jenkins/workspace/TestJob [TestJob] $ /bin/sh -xe /tmp/jenkins132166175190200986.sh + echo 'Hello, Jenkins!' Hello, Jenkins! Finished: SUCCESS
Next Steps
- Connect Jenkins to your version control system and set up webhook-triggered builds.
- Add build agents/nodes to distribute workloads across multiple machines.
- Integrate Jenkins with your deployment pipeline (Docker, Kubernetes, or your cloud provider's CLI).
- Explore additional plugins for testing, notifications, and artifact management.
For the full guide with additional tips, visit the original article on Vultr Docs.
Comments
No comments yet. Start the discussion.