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 Open JDK 8 package
sudo apt-get install default-jdk -y
Once install java, enter the below command
Verify Java Version
java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
Now lets do Jenkins installation
Jenkins Setup
Add Repository key to the system
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.
Now go to browser. enter public dns name or public IP address with port no 8080.This is how to select public DNS name:
Get the password from the below file
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste in the browser
Click on install suggested plug-ins.
Also create user name and password.
enter everything as admin. at least user name as admin password as admin
Click on Save and Finish. Click on Start to Use.
Maven
sudo apt install maven -y
you can type
mvn --version
you should see the below output.
Tomcat Installation
Tomcat is a web server or web container where java web application can be deployed by developers.
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
Click on this link to know how to make changes using Vi editor.
Change port no from 8080 to 8090
sudo vi /var/lib/tomcat8/conf/server.xml
you need to scroll down by clicking down arrow button in this file change the port no from 8080 to
8090 at line starting with <Connector port="
8080" protocol="HTTP/1.1"
setup an user in tomcat
sudo vi /var/lib/tomcat8/conf/tomcat-users.xml
Add more memory to JVM
sudo vi /etc/default/tomcat8
Look 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"
sudo systemctl restart tomcat8
sudo systemctl status tomcat8