Installing Tomcat

A free video tutorial from Eduonix Learning Solutions
1+ Million Students Worldwide | 200+ Courses
3.9 instructor rating •
241 courses •
1,213,597 students
Learn more from the full course
Learn DevOps with Jenkins All in One GuideBe a DevOps Guru and master CI and CD with Jenkins
04:19:29 of on-demand video • Updated December 2018
- Integrate CI and CD in your development process
- Learn to use Jenkins for process automation
- Work on a real world project and implement the concepts
- Learn professional tips and tricks for better Jenkins management
English
Hello everyone and welcome back. This is Ahmed again for Eduonix and this is beginning Jenkins
section 2 Jenkins installation. In the previous lecture we have seen
how we can install Jenkins on a myriad of options, myriad of hosts and platforms. Lets start by our first option here or one of our options which is
installing Jenkins as servlet or inside a java container as it is sometimes called. Sometimes it's also called an application server and for this lab we have chosen
Tomcat as our applications server because
it's lightweight compared to other fully fledged application servers
like WebSphere or Weblogic they're going to take a
lot of time to install and configure. We just want to
demonstrate Jenkins and not the application
server itself. So we have chosen Tomcat for those purposes. Again Jenkins needs
Java version 7 for a minimum and tomcat version 5 for the minimum. I could have gone through the steps
of deploying Java 8 and downloading and
installing tomcat. However vagrant has a box that has those components already installed. It can be used to for our Jenkins
installation. So let's have a look at our example
system. This is my terminal. This is my Mac. And I have already as you can see
here I have already installed vagrant on
this machine. So I could use it to create my machine that is going to be used for Jenkins. So in your home directory or whatever path you desire. In my case I'm going to use the home
directory. I'm going to create a new directory. I'm going to call it
a Tomcat. And vagrant actually works on a directory basis. This means that if I am inside this directory then the vagrant command I'm going to use is
going to manage all the machines that are running
inside this directory. Once I am outside the
directory I cannot use vagrant to manage the machines that are inside this
directory. I have to be inside the directory to manage the machines that are
installed or are open and are running there. Okay so I'm going to create a
directory for Tomcat because I want to host a machine
that has Tomcat pre installed on this
directory. So I want to have a friendly name or a descriptive name. The second step is to choose is to run vagrant init and vagrant init is the command that
will create something called a vagrant
file. A vagrant file is nothing more text
file that i am going to show it to you in a moment. This text file contains all the
instructions that vagrant needs to start the machine. It contains instructions like for
example network cards. If you want to forward some port
we're gonna come to this in a moment. If you want to have another user and the default user which is
vagrant. If you want to change the memory or the CPU that is used in a machine in addition to
other options even if you want to
configure the machine automatically through a
configuration management system like ansible or Chef or puppet or salt or even Docker you can do that using the vagrant file. So the vagrant init command is used to create this file and I need to add on I can actually pass in the name of the machine that I want to use. Or in our case the name of the box that I want to use and it's called emessiha. It's a strange name but it is the one that contains the
Tomcat installation /ubuntu64-java and i can optionally pass in the box version 1.0.0. Once i click enter as you can see here It has informed
me that I have vagrant file created in my directory. If I go inside directory and then this vagrant file I can see that it contains a lot of
options. They are all well commented and they are all well explained. As you can see here one of the most
important options here that I can configure or i can with is the config.vm Network. This one because this one is the option or the configuration that forwards
ports from the machine. The guest machine to the host
machine. The vagrant machine here is called
guest while the Mac my machine my local machine is called the host because it is hosting this guest, it is hosting this machine on its system. OK so if you want to access any port inside the guest machine you cannot because by default it uses something that is called NAT that is short for network address
translation. It is a way of protecting the network ports that are inside that are running inside the guest by preventing any access by preventing any external access to those ports except if you want to explicitly allow this access by forwarding the port internally to the host. In other words if I'm running web server inside the guest machine and this web server is running Of course by default on port 80. If I want to access this port from outside the vagrant host from the vagrant guest I would have
to use port 8080 on the local host. So if I want to access this website I will have to go to my browser and navigate to a local host or 127.0.0.1 which is the address of the local
host as you already know. Column 8080 and vagrant is going to translate or to forward any traffic that is
coming to port 8080 to the guest on port 80 and the other way around. Any traffic that is coming from this guest to the source of the traffic or to the user or the client that is requesting the
page it is going to be forwarded in the
same channel to the requesting host. So why this is important because we
are going to actually forwards the traffic that is coming to port 8080 on our guests because port 8080 is the new full port that Jenkins runs on or Tomcat runs on because tomcat as well runs on that 8080. Both of them actually run on 8080. Whether Jenkins is running as a
standalone application or inside tomcat both of them use the 8080 port. So I'm going to forward traffic that
is coming at Port 8080 on the host to the same port but on the guest. Why. Because the guest will be
running Jenkins or tomcat on Port 8080. I want the user to enter the same port when he or she accesses this application via localhost. I don't want to change the port. I want it to be 8080 as well and that is possible I can forward
the port to the same port or I can forward it
to a different port. It's up to me so I'm going
leave it like this 8080. And the next step is of course if you want to have any
other configuration you are free to do so
you can as you can see here change the memory you can change. You can even run a shell script that gets run as soon as the machine
is up or running. This is called a
provisioning the machine. Provisioning is one of
the devops terms that are used by devops engineers. So you can for example choose to run a shell script that will install Apache for example when the machine gets started. You can also use as we said any of the configuration managers or providers such as puppet, chef, ansible, salt and docker. Okay so you feel free to change this file whatever however you want. Once done save the file and the next step is issuing vagrant up. And in issue vagrant up vagrant will do one of two things. It will search for the box and the box it refers to the
templates by which vagrant pulls the image from and starts deploying it on your machine as a virtual machine or as a vagrant machine. If it finds this box on your system it is going to use it. If you haven't installed this box
yet or if you haven't downloaded this
box yet it is going to go and fetch that box from its default website which is
Atlas.hashicorp.com. And once done once the box is done downloading it's
going to use it for this installation as well as subsequent installations. So when I click enter on vagrant up and because I have already
downloaded this box before before starting this lab you are going to see that it's gonna
import the base box from my file system from my local machine instead
of having to go and download it from an external website. And this of course will save a lot
of time. So let's wait till the machines are
running. Notice here that vagrant is
forwarding ports the port that we have already configured 8080 is being forwarded to port 8080 and actually this machine is already is also preconfigured with some other software. It comes pre installed with Apache and also the MySql
database server. We don't need those we just need the
tomcat installation and now it's up and running. In order to access this machine all what we have to do is just issue vagrant. SSH like this and you are in. This is the machine. This machine already inside already has Tomcat installed. If you want to make sure Let's just clear the screen and we can run system CDL status tomcat. And as you can see here Tomcat is
active and running. This means that if I go
to a browser like this and use one of those windows that we have
already and localhost 8080 if I click enter as you can see here I have an installation of Tomcat. It is Tomcat 9 and as we have said the latest the least version of Tomcat that were needed is 7 so we have
version 9. It's already above the minimum requirements. So now we are ready to install
Jenkins on our Tomcat server. And that is going to be a starting
topic of our next lecture. So until then. See you next.