Atlantic.Net Blog

How to Install Jenkins on Rocky Linux 8

Jenkins is an open-source, widely used automation software tool. It is used in the software development life cycle to build, test, and deploy code automatically. Jenkins is written in Java and allows you to automate a series of tasks in order to complete the continuous integration process. It provides a simple and user-friendly web interface that allows you to manage complicated tasks through a web-based dashboard.

In this post, we will show you how to install Jenkins on Rocky Linux 8.

Step 1 – Install Java

Jenkins is a Java-based tool, so Java must be installed on your server. If not installed, you can install it using the following command:

dnf update -y
dnf install java-11-openjdk -y

Once Java is installed, verify the Java version using the following command:

java --version

Sample output:

openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Step 2 – Add Jenkins Repository

By default, Jenkins is not included in the RockyLinux 8 default repository, so you will need to create a Jenkins repo to your system. You can create it using the following command:

wget -O /etc/yum.repos.d/jenkins.repo

Next, download and import the Jenkins GPG key with the following command:

rpm --import

Next, verify the Jenkins repo using the following command:

dnf repolist

Sample output:

repo id                                                         repo name
appstream                                                       Rocky Linux 8 - AppStream
baseos                                                          Rocky Linux 8 - BaseOS
extras                                                          Rocky Linux 8 - Extras
jenkins                                                         Jenkins-stable

Step 3 – Install Jenkins

Now, you can install Jenkins using the following command:

dnf install jenkins --nobest

Once Jenkins is installed, start Jenkins and enable it to start at system reboot:

systemctl start jenkins
systemctl enable jenkins

You can now check the status of Jenkins using the following command:

systemctl status jenkins

Sample output:

● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
   Active: active (running) since Wed 2021-09-22 07:11:09 UTC; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5106 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
    Tasks: 13 (limit: 11411)
   Memory: 129.1M
   CGroup: /system.slice/jenkins.service
           └─5129 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/>

Sep 22 07:11:07 RockyLinux8 systemd[1]: Starting LSB: Jenkins Automation Server...
Sep 22 07:11:08 RockyLinux8 runuser[5113]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Sep 22 07:11:09 RockyLinux8 runuser[5113]: pam_unix(runuser:session): session closed for user jenkins
Sep 22 07:11:09 RockyLinux8 jenkins[5106]: Starting Jenkins [  OK  ]
Sep 22 07:11:09 RockyLinux8 systemd[1]: Started LSB: Jenkins Automation Server.

By default, Jenkins listens on port 8080. You can verify it with the following command:

ss -antpl | grep 8080

Sample output:

LISTEN 0      50                 *:8080            *:*    users:(("java",pid=5129,fd=135))

Step 4 – Configure Nginx as a Reverse Proxy for Jenkins

It is recommended to install and configure Nginx as a reverse proxy for Jenkins. First, install the Nginx web server with the following command:

dnf install nginx -y

After installing Nginx, create an Nginx configuration file for Jenkins:

nano /etc/nginx/conf.d/jenkins.conf

Add the following lines:

upstream jenkins {
  server fail_timeout=0;

server {
  listen 80;

  location / {
    proxy_set_header        Host $host:$server_port;
    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_pass              http://jenkins;
    # Required for new HTTP-based CLI
    proxy_http_version 1.1;
    proxy_request_buffering off;
    proxy_buffering off; # Required for HTTP-based CLI to work over SSL

Save and close the file when you are finished.

Next, verify Nginx for any syntax error:

nginx -t

Sample output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Please note if you get this warning message :

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

You must edit the /etc/nginx.nginx.conf file and add this line before the server block:

server_names_hash_bucket_size 64;

Finally, start the Nginx service and enable it to start at system reboot:

systemctl start nginx
systemctl enable nginx

Step 5 – Access Jenkins Dashboard

Now, you can access the Jenkins web interface using the URL from the web browser. You should see the following screen:
Jenkins initial password
Now, open your terminal and retrieve the Jenkins setup password using the following command:

cat /var/lib/jenkins/secrets/initialAdminPassword

Sample output:


Now, paste the above password and click on the Continue button. You should see the following screen:
Jenkins install plugins
Now, select ‘Install using suggested plugins‘ or ‘Select plugins to install‘. You should see the following screen:
Jenkins create admin user
Now, provide your admin user information and click on the Save and Continue button. You should see the following screen:
Jenkins provide website URL
Now, provide your Jenkins URL and click on the Save and Finish button. You should see the following screen:
Jenkins installed
Click on the Start Using Jenkins. You should see the Jenkins Dashboard on the following screen:
Jenkins Dashboard


Congratulations! You have successfully installed Jenkins with Nginx as a reverse proxy on RockyLinux 8. You can now implement Jenkins in your development environment and automate the development process. Get started with Jenkins today on a dedicated server from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year