Deploy Java Web App On Amazon Linux EC2 instance Using Tomcat

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone this is predict Josie and welcome to my youtube channel so today we are going to look into AWS ec2 instances and forties or main goal here is now we will going to create a Seaton instance and then we are going to deploy our Java based web application of our file so I will show you how we can do that and for that I will install all the prerequisite software's like Tomcat and Chava also and we will do some configuration changes in our XML files as well so let's get started with that so let's go to Amazon Web Services website first and then we need to login to our console so you just need to create amazon web services account first for that so I have my own account here created so let's PC to that we will go into easy do you can search any kind of service from here so let's say if you want to go to e said we can you just need to search it you here and you will be redirected to that services [Music] so now you can see the basic dashboard here where zero instances running so what we are going to do is we are going to create one instance here and we are going to deploy our web application on top of that so let's say we will say first launch instance and here you will get a list of all the available instance with different different flavors we can say so from this all this flavor first of all we will choose free tyranny so Amazon is giving free TF instances which is free which we can use for our education purpose and for some are any kind of work so for this from this list I am going to choose the first one that is Amazon Linux PMI and that is a 64-bit version so let's go into that we have to pass through some basic configurations here so I will give you some brief idea about that also so first of all it is a general-purpose ante to microservices so remember guys t2 micro is for the fleet here and this it will be highlighted like this also so there may be some other flavors like to you to small T to medium it t to large but as per your usage right they are chargeable so I will suggest first you need you people need to go with t2 micro and will go next with the configuration here so here it will give us all the configuration like how many number of instances you want okay and some basic things which we are not going to cover in depth so let's move forward by default it will give us 8 GB of size and the tour route volume with a UPS of 100 let's go next okay so here it will give us some review if you want to change anything we can still have a option to do that and so everything looks fine here so let's go and launch it now here I see this is a very important point when it comes to a particular instance creation and connection so whenever you are getting this screen remember you for the authentication purpose my EWS is giving you the option to choose your key value pair so let's say once you choose your key value pair using that key value pair only you are able to connect to your Linux machine using the SSH and using the SSH so I will show you how we are going to do that so first of all I am going to create a new key value pair okay and I will going to name it something so let's name it like for base okay and then you need to download this paper remember guys when okay it says like okay this is already exists okay so we will see code base one so make sure guys whenever you have this key pair keep it safe and keep it handy because once you lost it you are not able to retrieve it again so you have to terminate your instance and you have to start it again so just make sure to keep it safe so for my purpose I will keep it here okay so this is my code base 1 and let's go to our configuration again and and the last step is launch instance right so it will take some sort of time and you can view the logs and the status of your instance which is going to put up a particular second so here instances still it is currently pending we will give some time to it and we'll be come back shortly after once this is it's just got training so I'm pausing the video here okay so here we can see as our instance is up and running now so what we will do is we were just going to make one private key using which we are we are able to connect to this instance using our booty server so as you know that we have downloaded our Pam key so I am going to generate a PPK key out of that Pam typical stands for put t private key using that you can connect to your little skin cells so let me cue that particular so here we are going to use put occasion where we need to load our Pam give each video just downloaded okay so here I will choose all fine and you can able to see that Pam finally just thesis all right which we have downloaded okay and then we are going to save it as a private key it will ask us for the path and here I will give it like Oh base okay and then we are going to save it okay so we are done with our PP k key now I will show you that how here how we can connect to this instance is a protein so I will open put here and what I will do is we have to give we have to provide the hostname where we want to connect it and where where you can get it so let's say for this instance you will get your Public DNS this is your hostname okay you can get all the information here kind of a simple thing that what is our instance ID okay what is this said what is the type okay if you have connect collected and it with any elastic IP or not what is the security group security group here is one of the key area which I will take you through in couple of minutes so you can find your security group here also okay then you can have this public dns which which is this one only your IP address okay and so on so what we are going to is we are going to copy this DNS server from here and I'm going to paste it here okay and I am going to name it let's say for base okay and here we need to give our PPK file which we have just generated so to provide that people file you have to go to SSH in that path and here we need to browse that fire okay so this is my time I am going to browse it here and what I will do is I will going go back to session again and I will save this session so it will be here for my upcoming session so let's say if I want to come back tomorrow and if want to go to this instance again I do not need to follow all this process again I just need to click this and just open it so let's say yes so we will be in yes now we are into our ec2 instance so if you can see our IP address is 18 to 36 141 27 and we are connected to the same IP addresses here right so we need to follow a few basic things where we were going to install prerequisite applications and softwares like Tomcat and Java and I will take you through that okay so first of all we need to login as ec2 user okay and it will authenticate that and yes we are that so now if you see this command okay it is asking me to run sudo yum update command so what is that so basically it is asking us to run the update command so that my kernel and everything got updated and up to be in sync so let's execute that command okay and it is asking me for my optimization so I will press yes right and it will take some sort of thing so let's wait for a while okay so here we are done with our update okay so I'm going to figure this screen now okay and now we are going to install Java so before installing Java let's execute the Java command and see whether Java is already installed here or one so for that we will pass our - version and give us a version here so this seems like Java is already installed but let's say in case we don't want this Java version we want to work without 1.8 okay so for that what we needs to do so I will show you for that okay so what we will do is we will going to create our own directory and then we are going to install our Java and Tomcat both okay so I will take you through that ok so this is my root directory and I'm going to create a folder we can say in my user folder so what I do okay so let's say [Music] permission UNIX sorry yeah so this is a permission denied nervous so what we need to do is we need to login using the super user so for that we need to write sudo su ok and now we have the permission to create a directory over here so if you see now we have a Java holder got created so that speech into that sorry and now what we are going to do is we are going to install Java now how we can install so there are couple of different ways available to install any particular package in your Linux machine and out of that different different of ways I am going to follow one that is called using the URI for which we need to pass we get and we need to pass the you or either so it will fetch the package from that URI for you so that is we get okay for for accessing this we need to first install it in our Linux so let's do that okay so for that okay and it will install it so here it is saying nothing to do means we get is already installed here okay now what I'm going to do is I'm going to get a Java JDK URL okay from that we can able to download watch out so for some handy things I have already captured that and that is the URL called JDK 8 and that is a linux x 64 RPM event so I am going to use this URL I am going to share it with you guys also so it is better for you to understand it and see too okay and I'm going to paste it here okay let's see yes so it is downloading so we'll wait for a couple of seconds here and then I will install this because it is rpm so we need to install it this way okay so now if you list it you will find that rpm file in my java for now I've been nine if you need to install it okay so what is it one for that so it is iam again install and you are JDK version so this will install your java machine okay so it seems it is completed and now again we are going to execute that Java command to check the version and now you can see that current version is one point eight point zero and that's called one-for-one okay so a latest version is got updated now we have installed about Java now what we will do is we were going to install Tomcat for that I will show how we can do that again so let's go to Tomcat installation package okay here you will find a tar file so what we need to do is we just need to copy this link and we need to count it so look at and we just paste that thing okay so here it is now again if you list it you will find your Tomcat tar file is downloaded now again it is a tar file so what we need to do is we need to install it okay and to install a tar file we have a command called the guitar ex free F side followed by respected file okay see here so it got unpackage in my fault okay so you can find that unpackage folder here sorry it is not incredible color actually so what I will do is I will change the unwanted files now we don't require this tar file as we have our tradition package okay and along with that I will also we are good here and if you list it we find that we have a patch and JDK installed okay so this is the part where we need to provide the installation package now I will show you that what our configuration we need to do okay so this is there are few configuration which we need to do in in Tomcat server in terms of authorization of particular IP address to access it from outside and second one is to provide the managerial credentials to access the Tomcat homepage ok so I will show you in couple of seconds okay so let's go into patch a and that in this state so we have all the required folders available here okay so let's say let's okay let's first try to start the server game so for that what we need to do is we need to go into the theme and if you listed here we will guide or you will get all the SH bad files which is helpful to start your sugar so I will start the server okay and we'll see okay so it says server started okay but to cross verify it okay we need to check whether it is perfectly started or not for that we will use PS dot and - sorry - here and then a crab command okay so it is saying like root is working on this particular IP so I not I paid port but it seems like it is not working so let's say how you will check it so if we write W K instead T P they call a new local host : you will find a message that failed okay connection refused and why so this is because we are not logging as super user currently we have now and see now okay so we have holy stuff for class loader here with all the locks okay and now if you try to cut your file cat the access of the local host okay see it's connected or index dot HTML Scott saved okay so it says like your you are able to connect to your path okay so now let's say our service got started right so if we can able to access over X 0 H 0 port from our browser also right so let's try this one that's good to try so whatever do is I will copy this URL and simply follow 8 0 pages it should work right it seems it is not walking again because we still need to do some sort of configuration in our config file okay and I will show you what all kind of quantitation we need to do okay so let's go there okay you come back to my parent directory okay so we have by default let's say whenever you download your Tomcat server right by default Tomcat has restricted its port and accessibility to the local machine only so whenever you type like HTTP colon localhost:8080 it will work perfectly fine because you are accessing it from your local machine but let's say whenever try to access your Tomcat from at some other machine or some IP address okay it won't allow you okay so in our case we are this we have installed in our booty server ok sorry we have installed it in our index machine ok and if you try to perform that localhost:8080 using that same machine using a boot it is working perfectly fine but when you are trying to access your Tomcat using the IP address which Amazon has given you from the browser it won't allow you ok so it is restricted so first of all we need to remove that that restriction so I will show you how we need to do that ok so for that you need to go to by the folders I will take you try and take you throw that in that we have a manager and in that we have meta-inf ok if you see there you will find a context or XML and this is the file which we need to modify ok to modify a particular file what is the command it is again manager meta-inf and then fine okay that's going to matter now if you see here okay if you read it carefully you will come to understand that it is allowed only to 127 caught dot 0 dot 0 dot to 1 okay so that represent you have to local machine only so what we will do is we will comment this out ok so we will remove this restriction so to change any particular file in Linux special we have to press I so you will find an insert statement here and then you can change it so we will going to comment this out ok so it and now what I will do is I will press escape so I'm no longer in insert more I will write : W Q okay so this will stay on my file and we will exit from fine okay so I will cross verify it again we will go you go into that file again and we will check ok so yes so it is man it is commented ok so no issues we will just go back and what we will be going to the ways we are going to restart our server because we have changed the configuration okay so what I will do is to and then I will pop this star okay so we are we have started our server here and again we are going to check ours okay so don't catch right yeah we are good here okay and let's try again now so we have already moved our configurations we have removed the restriction and we will try to try it again okay so it should work ideally now right we will see whether it will work or not okay and it seems like it is not working okay and why because we haven't configured our firewall of ec2 instance which I have I had discussed in our startup what's it chaotic room so we need to do some configuration here also again so consider guys consider this security group as your firewall for this particular Linux machine which you have created okay so you have inbound and on one section available here so what this will indicate you so what is inbound so all the inbound requests will pass through this and all the admin request will pass through this so we need to bypass our services okay so we will go to inbound and there you will find all the different different rules which you have implemented so by default it is as a such certification sorry as such port is open with port range in 2002 TCP server or product okay why this because we need to connect it using putty so by default they and they are giving us this but apart from this there is nothing so we need to edit it and we to add a rule here so if you click here you will get all the list of residuals yeah well you can find as a search SMTP HTTP okay or three HTTP so you can configure whatever you truly want according to your requirement so what for this purpose we are going to use this custom TCP rule here okay and what I will do is I will create I will give it a zero it is my Tomcat part okay and I will keep it custom which will allow any particular IP address to access my Tomcat ok so we'll save it and we will give it a try one second and yep we are good here okay so guys if you have not tastes when I change this particular port right when I have given T requests in my inbound we didn't restarted our server or we'd be--we'd perform any particular thing okay so that is the beauty of easy to instance whatever we you will configure in your inbound and outbound service you don't need to restart your instance and as well as your server inside that now we are inside our target now we need to deploy our application here so for that we need to access our manager tab but we are not sure that what is the user ID and password for that so what we will do is we've been going to create or we can say we care if we were going to update that XML file for s per our user ID and password so I will show you that how they're going to do it okay so currently we are in pin so what I do is I will come back to a parent directory I will list it and yes so we have to go to conf okay to make the change so I gone and get user dot XML okay here you will find that current rule is commented okay so control is commented we can't do anything into that so for that what we will do is we will going to put over key value pair for username password so first of all I will press I and that will put me into insert mode and I will copy paste my user ID and password so for the ease of you guys I have already copied it here and I will share it with you in the YouTube description so what are we do is we just paste it here okay so this is what I will find it to do and I have provided the username is admin and password is admin okay so nothing else we need to do is in this portion okay so I will escape it and I will and yes it is that okay so they did create it now we have changed the target user XML so for that we have to also restart our server okay so let's go to our server that is okay and what I will do is have is shut down once this server and I will again start my server and we will check okay yep so let's give it a try here manage your app is asking me for my username and password and I widened so now we are into our Tomcat deployment page okay so from here guys you can deploy your web applications straight away without any hassle okay so I will show you how we are going to do that so let's let me open my clips let me close this and I will create a new web based application and have it application here okay I will going to name first we are not going to do watching this project actually so we will have it one simple G is page only and I will demonstrate you that how we are going to do that so let me create one JSP page here first of all let me name X dot JSP and finish it and we need to do some configuration changes in web dot XML also so this is I default by comm page we don't require that so my server will start it will by default try to look for this index dot JSP and that it will be going to find into web content which is this one and it will load it so we'll change few things here and I will name it okay we'll keep it this simple on yoga or timing and I will try to run it once ever so we will check it once whether everything is working perfectly fine or not okay it's the target server it will put up and we were going to check this so it will start in a couple of second it seems yeah so we are good here okay and yes my page is also popular popping up okay so let's try to create a war file and try to deploy it okay so we will export it as a war file I will give the destination where I want this so this is my destination I will save it and finish it okay now I will go to my page and I will choose the same cache file so that more file is this one and I will deploy it now see nice it came here so it is now into the root directory of Tomcat okay if you are good in target you can go through your tomcat directory where you will find the or in manager you will find root and into root you will find this as you have project okay so when you click it see now your application pops up so see the thing is now it is your web application okay so using this link you can access your application from anywhere so we can say you have deployed your application on server okay so this is just a simple example okay which I have demonstrated here and and now it is accessible to whole point we can say okay so for time being guys I'm you know pausing this video for for this particular session okay so in couple of days I'm coming with one new video where I'm going to show you that how we are going to connect to the database of ec2 for Amazon okay Amazon is giving so many different different services here out of that database is also there so what we will try to do is we one called oppression in our web application and that that petition is going to store the data and retract the data from the database of Amazon Web Services okay so let's say if you have something in production let's say when you try to put some thing in production you don't need to worry about even your data businesses well Amazon will take care of your databases you just need to point to your database and you have to provide the JDBC according to your database you unobtanium in your project so we were going to cover that part in coming in upcoming video and the aterna grits I will also going to describe you about would commit Corbett and code deployment as well so in theory we are going to host our code in github and from Keita we are going to patch it with AWS is it reduces services ok so that is what my upcoming videos will contain ok guys so be in line and try practicing if you have any question or something you can post it here ok so thank you so much guys for watching this video hopefully you'll enjoy it thank you so much
Info
Channel: Cloud Geeks
Views: 80,765
Rating: undefined out of 5
Keywords: AMAZON WEB SERVICE, JAVA, DEPLOYMENT, EC2
Id: _d-c9uGcUrU
Channel Id: undefined
Length: 36min 3sec (2163 seconds)
Published: Fri Apr 20 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.