Thursday, April 1, 2021

Setup Jenkins and Tomcat server

Login to aws instance or VM and add user

useradd devops

passwd devops

Edit this file /etc/ssh/sshd_config and enable PasswordAuthentication

PasswordAuthentication yes

Restart SSHD Service

systemctl restart sshd
------------------------------------------------------------------------------------------------------------
Install java 1.8 version

yum install java-1.8* -y
















Set java path : /root/.bash_profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64
echo $JAVA_HOME
source /root/.bash_profile
------------------------------------------------------------------------------------------------------------
Download Jenkins repo

Ref : https://docs.aws.amazon.com/aws-technical-content/latest/jenkins-on-aws/installation.html
 
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo

rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
yum install jenkins -y 
service jenkins start   or  systemctl start jenkin
Open 8080 port 
http://localhost:8080/
Password location :  /var/lib/jenkins/secrets/initialAdminPassword
 
Secure Jenkins server

1. Change admin password

2. Remove the secret password file ( /var/lib/jenkins/secrets/initialAdminPassword )

3. Configure Global Security - Enable Security

4. Configure Global Security - Enable Project-based Matrix Authorization Strategy and role base Authorization

5. Configure Global Security - Disable SSH Server

------------------------------------------------------------------------------------------------------------
Install Maven & Git  installation and configuration 
 
Ref : https://maven.apache.org/download.cgi
 
Create maven folder in opt
Install wget and downloads below maven packages

wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz

###  /root/.bash_profile  ######
 
# User specific environment and startup programs
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64
 
M2_HOME=/opt/maven/apache-maven-3.6.0
M2=$M2_HOME/bin
PATH=$PATH:$JAVA_HOME:$HOME/.local/bin:$HOME/bin
------------------------------------------------------------------------------------------------------------
Select maven_invoker and github
 
And path in Global Tool Configuration





























------------------------------------------------------------------------------------------------------------

Install Publish Over SSH  plugging for Ansible integration and send build artifacts over SSH



Download below tomcat package

wget http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz
 
Ref : https://tomcat.apache.org/download-80.cgi
 
cd /opt/apache-tomcat-8.5.38/bin/      -----  After extract you  get this folder
 
chmod +x startup.sh  shutdown.sh     ----- Give execute permission to  startup.sh and  shutdown.sh 
 
 
Create soft link 
ln -s /opt/apache-tomcat-8.5.38/bin/startup.sh /usr/bin/tomcatup
ln -s /opt/apache-tomcat-8.5.38/bin/shutdown.sh /usr/bin/tomcatdown
 
Tomcatup   -------------------------   start tomcat
 
 ps -ef |grep tomcat   -----------------------  check tomcat is running or not
 
/opt/apache-tomcat-8.5.38/conf   ----------   go to conf directory and edit server.xml 
 

Edit server.xml and change tomcat port
 


 




Change 8080 to 8090
 
Restart tomcat
 
tomcatdown   --------------  stop the service
 
tomcatup      ---------------   start the service



















URL : http://ServerIP:8090/manager/










Solution for above issue: 
 find / -name context.xml
/opt/apache-tomcat-8.5.38/conf/context.xml
/opt/apache-tomcat-8.5.38/webapps/host-manager/META-INF/context.xml
/opt/apache-tomcat-8.5.38/webapps/manager/META-INF/context.xml
 
Edit both the files and uncomment below line






Restart tomcat
 
tomcatdown   --------------  stop the service
 
tomcatup      ---------------   start the service


How to set user and password  add following roles
 
Edit this file /opt/apache-tomcat-8.5.38/conf/tomcat-users.xml
 
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status"/>
<user username="deployer" password="deployer_user" roles="manager-script"/>
<user username="tomcat" password="s321cret" roles="manager-gui"/><feff>

---------------------------------------------------  END  -----------------------------------------------------















No comments:

Post a Comment