Skip to content

Jenkins installation on Centos behind Nginx

Step-1: Setting up Timezone


sudo timedatectl set-timezone Asia/Kolkata

Step-2: Download and install tools


sudo yum install -y policycoreutils-python wget git

Step-3: Download Java


sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm"

Step-4: Install java


sudo rpm -ivh jdk-8u141-linux-x64.rpm

Step-5: Setting Java Environmental Variables


sudo vi /etc/profile.d/java.sh


#!/bin/sh
JAVA_HOME=/usr/java/jdk1.8.0_141
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH
export CLASSPATH=.

Step-6: Executing and sourcing the env file


sudo chmod +x /etc/profile.d/java.sh

source /etc/profile.d/java.sh

Step-7: Download Jenkins


sudo wget https://pkg.jenkins.io/redhat-stable/jenkins-2.60.3-1.1.noarch.rpm

Step-8: Install Jenkins


sudo rpm -ivh jenkins-2.60.3-1.1.noarch.rpm

Step-9: Create JENKINS_HOME directory


sudo mkdir /opt/mycicd

sudo chown -R jenkins:jenkins /opt/mycicd

Step-10: Edit Jenkins Options file


sudo vi /etc/sysconfig/jenkins
JENKINS_HOME=/opt/mycicd

Step-11: Start Jenkins


sudo systemctl start jenkins

sudo systemctl enable jenkins

Step-12: Download Nginx


sudo wget https://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.12.1-1.el7.ngx.x86_64.rpm

Step-13: Install nginx


sudo rpm -ivh nginx-1.12.1-1.el7.ngx.x86_64.rpm

Step-14: Starting Nginx


sudo systemctl start nginx

sudo systemctl enable nginx

Step-15: Nginx Jenkins Configuration

sudo vi /etcnginx/conf.d/jenkins.conf


upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}

server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name jenkins.yebbare.com;

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;

if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}

Step-16: Reload Nginx Configuration


sudo nginx -t

sudo nginx -s reload

Step-17: Nginx SELinux Module for Jenkins reverse proxy


sudo cat /var/log/audit/audit.log | grep -i nginx | grep -i denied | audit2allow -M skynginx

sudo semodule -i skynginx.pp

Shashi View All

A passionate devops and automation engineer

One thought on “Jenkins installation on Centos behind Nginx Leave a comment

Leave a comment