Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Monday, June 1, 2020

How to change Default port for Tomcat | Change Tomcat Default port 8080

Tomcat default port is 8080. That can be changed by modifying server.xml of Tomcat.

Change port no from 8080
1. Locate server.xml, for Ubuntu it is at below location:

2. sudo vi /var/lib/tomcat8/conf/server.xml
Let's say you like to change from 8080 to 8090





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">

Restart Tomcat after changes

sudo systemctl restart tomcat8

Wednesday, May 13, 2020

Install Tomcat using Ansible playbook on Ubuntu - Install Tomcat on Ubuntu using Ansible playbook

Playbook for installing Tomcat 9 on Ubuntu using Ansible Playbook

sudo vi installTomcat.yml
---
- hosts: My_Group
  tasks:
    - name: Install Tomcat 9 on Ubuntu
      become: yes
      apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time=3600
      with_items:
        - tomcat9

sudo ansible-playbook installTomcat.yml


This is the execution result of Ansible playbook.

Wednesday, March 4, 2020

What is Tomcat | Why we need Tomcat Container?

What is Tomcat | Why we need Tomcat Container?
  • Apache Tomcat is a open source java based web server
  • It is also a web container for deploying Java based web applications - Java servlets and JSPs
  • It is one of mostly used web servers for hosting java web applications. 
Web application (or webapp) unlike standalone application, runs over the Internet. Examples of webapps are google, amazon, facebook and twitter.


Apache Tomcat is usually used as a Servlet Container even though Tomcat has a fully functional HTTP Server to serve static content. In most of production, Tomcat is used in conjunction with Apache HTTP Server where Apache HTTP Server attends static content like html, images etc., and forwards the requests for dynamic content to Tomcat. This is because Apache HTTP Server supports more advanced options than that of Tomcat.

Tomcat is both Web server and web container

Generally, a program that accepts incoming HTTP connections is called a web serverIn that case apache tomcat is a web server as it supports HTTP protocol and it is also a web container as it supports Java server pages (JSP)/servlet,Application programming interfaces(APIs) as well. 

Friday, September 20, 2019

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

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
Append debian package repo address to the system

echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list

sudo apt-get update
Install Jenkins
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)
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
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-script"/>

<user username="tomcat" password="password" roles="manager-script"/>



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


you may get message that says tomcat is active running.
press q for quitting from that window.
Now go to browser, copy public DNS
http://Ec2_public_dns_name:8090
 
You should see a page that says.
It works!!!!

That's it. You have setup Jenkins and Tomcat successfully!!

Please watch here for live demo:

Monday, August 5, 2019

Setup Tomcat8 on Red Hat Enterprise Linux 8 - How to install Tomcat 8 on Red Hat 8

Welcome to setting up Tomcat 8 on RedHat Linux 8.

Please find below steps for setting up Tomcat 8 on RHEL 8.

update package

sudo yum update

Install wget
sudo yum install wget -y
sudo yum install unzip -y

Java Installation

Download Java from Oracle site.

sudo wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm'

Install from RPM
sudo  rpm -i jdk-8u141-linux-x64.rpm

java -version

make sure Java version appearing fine.

Tomcat Installation

cd /opt

sudo wget http://apache.osuosl.org/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.zip

unzip Tomcat

sudo unzip apache-tomcat-8.5.43.zip

create a symbolic link 
sudo ln -s /opt/apache-tomcat-8.5.43 /opt/tomcat

Create user for tomcat

Create a user for running tomcat and give required permissions.
sudo useradd tomcat
sudo chown -R tomcat:tomcat /opt/apache-tomcat-8.5.43
sudo chmod +x /opt/tomcat/bin/*.sh

Create tomcat 8 as a service

sudo vi /etc/systemd/system/tomcat.service

[Unit]
Description=Tomcat
After=syslog.target network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

ExecStart=/opt/tomcat/bin/catalina.sh start
ExecStop=/opt/tomcat/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target

Re-load systemd

sudo systemctl daemon-reload

Restart Tomcat8 as a service

sudo systemctl start tomcat

Verify Tomcat service is running
sudo systemctl status tomcat

Enable as a service

sudo systemctl enable tomcat



Thursday, July 12, 2018

Install Tomcat 8 on Ubuntu 16.0.4 - How to install and configure Tomcat 8 on Ubuntu 16.0.4

Tomcat 8 Installation

sudo apt-get update
sudo apt-get install tomcat8
sudo apt-get install tomcat8-docs tomcat8-examples tomcat8-admin
sudo cp -r /usr/share/tomcat8-admin/* /var/lib/tomcat8/webapps/

sudo vi /var/lib/tomcat8/conf/tomcat-users.xml
Go 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"/>



sudo vi /etc/default/tomcat8
Look for the line starting JAVA_OPTS and comment that line by adding # and copy 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

Now go to browser, enter ip address or DNS name of server with port no 8080

You will see a page that says It Works!

That's is Tomcat is successfully installed on Ubuntu

Monday, October 16, 2017

Tomcat 8 hung on Ubuntu 16.0.4


Apply the below fix when you have tomcat not starting issues:
Actually, by setting the following in /etc/default/tomcat8, I was fine:
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"