How to Install Jenkins on CentOS 7

Jenkins is a popular open source CI (Continuous Integration) tool which is widely used for project development, deployment, and automation.

This article will guide you through the process of installing Jenkins on a Vultr CentOS 7 server instance. In order to facilitate visitors’ access, Nginx will also be installed as the reverse proxy for Jenkins.


Before proceeding, you must have:

  • Deployed a Vultr CentOS 7 server instance from scratch.
  • Logged into your machine as a non-root user with sudo privileges.

Step 1: Update your CentOS 7 system

One of the Linux system administrator’s best practices is keeping a system up to date. Install the latest stable packages, then reboot.

sudo yum install epel-releasesudo yum updatesudo reboot

When the reboot finishes, login with the same sudo user.

Step 2: Install Java

Before you can install Jenkins, you need to setup a Java virtual machine on your system. Here, let’s install the latest OpenJDK Runtime Environment 1.8.0 using YUM:

sudo yum install java-1.8.0-openjdk.x86_64

After the installation, you can confirm it by running the following command:

java -version

This command will tell you about the Java runtime environment that you have installed:

openjdk version "1.8.0_91"OpenJDK Runtime Environment (build 1.8.0_91-b14)OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

In order to help Java-based applications locate the Java virtual machine properly, you need to set two environment variables: “JAVA_HOME” and “JRE_HOME”.

sudo cp /etc/profile /etc/profile_backupecho 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profileecho 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profilesource /etc/profile

Finally, you can print them for review:


Step 3: Install Jenkins

Use the official YUM repo to install the latest stable version of Jenkins, which is 1.651.2 at the time of writing:

cd ~ sudo wget -O /etc/yum.repos.d/jenkins.repo rpm --import install jenkins

Start the Jenkins service and set it to run at boot time:

sudo systemctl start jenkins.servicesudo systemctl enable jenkins.service

In order to allow visitors access to Jenkins, you need to allow inbound traffic on port 8080:

sudo firewall-cmd --zone=public --permanent --add-port=8080/tcpsudo firewall-cmd --reload

Now, test Jenkins by visiting the following address from your web browser:


Step 4: Install Nginx (optional)

In order to facilitate visitors’ access to Jenkins, you can setup an Nginx reverse proxy for Jenkins, so visitors will no longer need to key in the port number 8080 when accessing your Jenkins application.

Install Nginx using YUM:

sudo yum install nginx

Modify the configuration of Nginx:

sudo vi /etc/nginx/nginx.conf

Find the two lines below:

location / {}

Insert the six lines below into the { } segment:

proxy_pass;proxy_redirect off;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;

The final result should be:

location / {    proxy_pass;    proxy_redirect off;    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;}

Save and quit:


Start and enable the Nginx service:

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

Allow traffic on port 80:

sudo firewall-cmd --zone=public --permanent --add-service=httpsudo firewall-cmd --reload

Finally, visit the following address from your web browser to confirm your installation:


Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

No comments

Powered by Blogger.