Jenkins setup - Install Java, Jenkins, Maven, Tomcat on Ubuntu EC2 - How to install Java, Jenkins, Maven, Tomcat on Ubuntu EC2
Please follow steps to install Java, Jenkins, Maven, Tomcat on Ubuntu EC2. Jenkins is a java based application, so you need to install Java first.
Java Setup on Ubuntu
sudo apt-get update
Install Java 11
sudo apt-get install default-jdk -y
Now lets do Jenkins installation
Jenkins Setup
Add Repository key to the system
Add Repository key to the system
This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system:
/usr/share/keyrings/jenkins-keyring.asc > /dev/nullThen add a Jenkins apt repository entry:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \https://pkg.jenkins.io/debian-stable binary/ | sudo tee \/etc/apt/sources.list.d/jenkins.list > /dev/null
Update your local package index, then finally install Jenkins:
sudo apt-get update
sudo apt-get install jenkins -y
The above screenshot should confirm that Jenkins is successfully installed.
Access Jenkins in web browser
Now Go to AWS console.
Click on EC2, click on running instances link. Select the checkbox of EC2 you are installing Java and Jenkins.
Click on Action.Copy the value from step 4 that says --> Connect to your instance using its Public DNS:
Now go to browser. enter public dns name or public IP address with port no 8080.This is how to select public DNS name:
Unlock Jenkins
You may get screen, enter the below command in Git bash( Ubuntu console)
Also create user name and password.
enter everything as admin. at least user name as admin password as admin
Maven
Maven is a build tool used for building Java applications. You can install Maven by executing below command:
sudo apt install maven -y
Maven is a build tool used for building Java applications. You can install Maven by executing below command:
sudo apt install maven -y
Tomcat Installation
Tomcat is a web server or web container where java web application can be deployed by developers. DevOps best practices dictate that Tomcat be installed on a server of its own. The reason is that if your Jenkins server is down, your Tomcat server will not be down as well. In that case, you will only need to setup your Jenkins server, not Tomcat server too. This is important because as we've noted above, Tomcat is a web server that hosts our application. We do not want our application to be own for nay reason whatsoever!!!
Tomcat is a web server or web container where java web application can be deployed by developers. DevOps best practices dictate that Tomcat be installed on a server of its own. The reason is that if your Jenkins server is down, your Tomcat server will not be down as well. In that case, you will only need to setup your Jenkins server, not Tomcat server too. This is important because as we've noted above, Tomcat is a web server that hosts our application. We do not want our application to be own for nay reason whatsoever!!!
Tomcat can be installed by executing below commands:
sudo apt-get update
sudo apt-get install tomcat8 -y
sudo apt-get update
sudo apt-get install tomcat8 -y
sudo apt-get install tomcat8-docs tomcat8-examples tomcat8-admin -y
sudo cp -r /usr/share/tomcat8-admin/* /var/lib/tomcat8/webapps/ -v
Tomcat default port is also 8080. If you have already used 8080 for Jenkins, then you need to change from 8080 to 8090. You can change by modifying server.xml
sudo vi /var/lib/tomcat8/conf/server. xml
setup an user in tomcat
sudo vi /var/lib/tomcat8/conf/tomcat- users.xml
sudo vi /var/lib/tomcat8/conf/tomcat-
Scroll down all the way to the end of the file,
Add the below lines in second last line above (above </tomcat-users>)
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="password" roles="manager-gui,manager-script"/>
Add more memory to JVM
sudo vi /etc/default/tomcat8Look for the line starting JAVA_OPTS and comment that line by adding #.
Add the below line:
JAVA_OPTS="-Djava.security. egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"
JAVA_OPTS="-Djava.security.
sudo systemctl status tomcat8
you may get message that says tomcat is active running.
















No comments:
Post a Comment