Skip to content

Jenkins installation on Centos behind Nginx

Step-1: Setting up Timezone

[code lang=”bash”]

sudo timedatectl set-timezone Asia/Kolkata

[/code]

Step-2: Download and install tools

[code lang=”bash”]

sudo yum install -y policycoreutils-python wget git

[/code]

Step-3: Download Java

[code lang=”bash”]

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”

[/code]

Step-4: Install java

[code lang=”bash”]

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

[/code]

Step-5: Setting Java Environmental Variables

[code lang=”bash”]

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

[/code]

[code lang=”bash” title=”Java Environmental Variables”]

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

[/code]

Step-6: Executing and sourcing the env file

[code lang=”bash”]

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

source /etc/profile.d/java.sh

[/code]

Step-7: Download Jenkins

[code lang=”bash”]

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

[/code]

Step-8: Install Jenkins

[code lang=”bash”]

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

[/code]

Step-9: Create JENKINS_HOME directory

[code lang=”bash”]

sudo mkdir /opt/mycicd

sudo chown -R jenkins:jenkins /opt/mycicd

[/code]

Step-10: Edit Jenkins Options file

[code lang=”bash”]

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

[/code]

Step-11: Start Jenkins

[code lang=”bash”]

sudo systemctl start jenkins

sudo systemctl enable jenkins

[/code]

Step-12: Download Nginx

[code lang=”bash”]

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

[/code]

Step-13: Install nginx

[code lang=”bash”]

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

[/code]

Step-14: Starting Nginx

[code lang=”bash”]

sudo systemctl start nginx

sudo systemctl enable nginx

[/code]

Step-15: Nginx Jenkins Configuration

[code language=”lang=bash””]

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

[/code]

[code lang=”bash” title=”Jenkins Reverse Proxy Conflicts”]

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;
}
}
}

[/code]

Step-16: Reload Nginx Configuration

[code lang=”bash”]

sudo nginx -t

sudo nginx -s reload

[/code]

Step-17: Nginx SELinux Module for Jenkins reverse proxy

[code lang=”bash”]

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

sudo semodule -i skynginx.pp

[/code]

17.38504478.486671
Advertisements

Shashi View All

-== Superman ==-

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.