AWS Labs: Hosting multiple website on single EC2 | Multiple IP | EC2 Practical | AWS Tutorial |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to my channel as you know that we are doing a series on ec2 instances hands-on and this is a yet another video in that particular series and in this video we are going to see how we can host multiple website on a single ec2 instance right so let us see what we are going to study from this video so first of all we will be provisioning secondary private ip addresses and the elastic ip addresses to our ec2 instances right so in order to you know allow multiple websites or multiple web page to run on your one ec2 instance we will be requiring elastic ip addresses or the private ip addresses for the same so we're going to see how we can provision them next we will be actually learning how to get our secondary ip recognized by our operating systems because when we launch an ac2 instance it is provided with with a single public ip and a single private ip right so after that what happens uh we have to make them recognize with our you know the underlying operating system of our ec2 instance we're going to see how we can do that next thing is that then we will be creating our two different web pages on our apache web server and this we have actually seen beforehand also and then we will be actually associating those web page with our different elastic ip and with those elastic ips we will be actually you know making those web page run right so before starting the hands-on let us first understand the importance of having multiple ip addresses associated with our ac2 instance right so there are multiple uses of having more than one elastic iep address first of all elastic rp address is a static static ip address that is associated with our ec2 instances we know that when we stop our instance the public iep of our instance get lost right so what we have to do we have to associate our ec2 instance with an elastic ip so that it can uh you know stay permanent with our ec2 instance right so we can have multiple ip addresses multiple private ip addresses as well as multiple elastic ip addresses associated with our ec2 instance so it has a lot of uses so first of all the we can use them to host multiple website on a single server which we are actually going to uh you know view in this particular video using multiple ssl certificates we won't be requiring these certificates because because we will be just doing this as a hands-on and when we do it in real life it that will be requiring actually the secure socket layer certificates also but we can host multiple websites for that we will be requiring the multiple ip addresses or we can use them to operate network appliances such as firewall or a load balancer that can have a multiple ip address for each network interface we can also use multiple ips to redirect internal traffic to a standby instance in case any instance get failed right so in case of failure we can reassign the secondary ip address to a standby instance so that we can mask that particular failure so this will be a little uh long hands-on and it will be having a lot of steps to you know follow so let us start and go to our aws management console now we are in our aws's management console and our first step will be to install an ec2 instance with an apache web server so this we have already seen in our previous videos so i shall be doing the same steps but in a quicker manner so i do not have any ec2 instance running right now so i will be launching one instance linux2ami the instance type will be t2 micro all the details will be default but in the place of user data i will be using the script to install start and enable http server that is the apache web server this is the user data that we have used in a lot of videos before also right so this is the user data which is i think do not having any error right so add a storage i won't be requiring any storage add tags yes so the name of my ec2 instance will be multiple web server right so it is it will be hosting multiple websites so i have named it like this and because the apache web server is working so i need port 80 to be enabled so i'm just selecting a security group which has port 22 port 443 and port 80 enabled over it that is ssh http and http s review and launch so i think everything is fine launching the instance with my existing key that is my linux key and launch so now what i have done is i have installed an apache web server on an ac2 instance and the instance has been launching right now so i will be clicking on view instances and yes the new instance is launching after some time this will be you know converted into running state so now the instance is running select your ec2 instance go to your public ip open up a new tab and just copy paste your public ip over here and press enter and you can see that the test page of apache is working very fine right so that was the first step where we have just launched our ec2 instance now you can see that with our ec2 instance if i click on the information related to it i have only one public ip associated with it one private ip address associated with it and i do not have any other ip addresses right now right so elastic ip address is also showing dash right it is blank so now the next step will be associate one more private ip addresses to my ec2 instance so uh keeping my instance selected i will be going to the actions networking and manage ip addresses right so you will be coming on this page that is manage ip addresses right so clicking on this you can see that one private ip addresses is actually assigned to your ec2 instance and now i will be just clicking on assign new ip address right so uh i will be actually i will be giving it an customized ip address so just copy the above ip and you can give 1 20 right so i have given this ip address in sync with this one and just click on save and confirm right so just refresh it once and now you can see that you have successfully completed the request of actually assigning a secondary ib address to your ec2 instance so now how we can actually see that the ip addresses have actually been associated with your uh you know ec2 instance or not for that we have certain commands so uh for that case i have to ssh into my ec2 instance right so i will be going to connect and copying this command over here opening my powershell and pasting it over here and now i will be logged into my ec2 instance right so now i am in my ec2 instance right so now i will be checking how many private ip addresses are associated with my ec2 instance right so i will be changing this permission to the super user right and for checking how many ip addresses are actually associated or recognized by your operating system you can enter the command i p a d d r space li right and if you press enter you can see that over here there is only one private ip that is associated with your ec2 instance so there is no other ip address but now you have seen that i have assigned another ip address that was 220 right dot 220 everything was same but the end was 220 but you can see that there is no such entry over here only one ip is visible so what we have to do we have to make it actually realize uh the operating system that yes now it have two private ip addresses right so for that what you have to do you have to type another command that means you have to restart your service network right so what you have to do you have to restart your network so for that you have to type sudo service network restart right and enter right so it is restarting the system and it's working very fine now you can use this command again that is ipaddr li and press enter and now you can see that it has two ips showing one is 172 31 29 and 218 and the next one is with 220 right so now what we have done we have actually made our operating system recognize my second secondary ip now at this point of time we are you know in a state to use both the private ip addresses of our ec2 instance so this step is really mandatory so now coming back to our management console and to our instance and so with this we have completed the second step that is we have associated our ec2 instance with two uh private ips so what i actually need is i need to make a note of these two private ips for my reference purpose right so i'm just copying the one ip address and paste it over here and i will also be copying the second ip which is 220 right and paste it over here also so these are my two private ip addresses right the second step will be allocating multiple elastic ip address with your ec2 instance so on the left hand side of the tab go to network and security click on elastic eyepiece as you can see that i do not have any elastic ip address in this region so i will be allocating one so click on allocate elastic ip address the region is fine everything is set to by default and allocate one elastic ip right so you can see that one ip address is now been allocated in this particular region but we have to host two websites right so we will be requiring one more elastic ip so uh go again to allocate elastic ip and allocate one more to it right so now you can see that i have allocated two elastic ip addresses in this region but yet these elastic ips are not associated with any instance so the next step will be to associate elastic eyepiece with my ec2 instance so stay on this page only right select one of the elastic ip go to actions and click on associate elastic ip address right so i am associating this elastic ip with my instance and the instance will be my multiple web server and here i will be choosing one of my private ip address so remember one elastic ip for one private ip right so for this particular elastic ip i am selecting my first private ip address right and i am just associating with it right so remember that for this elastic ip if i copy it right i have associated it with my first private ip address so i am just making a note of it right now so now you can see that one of my ip that is this 55 one is associated with my instance now associate the second elastic ip with your instance so go to actions associate elastic ip and this time select your instance only and this time map it with your secondary ip address right so this is my secondary ip address and click on associate right so again make a note of it that this particular elastic ip is mapped with my secondary ip address right so i have just copied it down over here also right so now you can see that both of my elastic ips are actually now associated with my ec2 instance now so what the next step we are going to do is we are going to you know again ssh into our ec2 instance on which the apache http server was installed and now we will be creating two different web pages right so for that go back to your uh you know the ec2 instance and just and you can see that it will be now not be working remember that here we have ssh into our ec2 instance with its public ip that is 54 167 something right 54 167 something but now if you go to your ec2 instance and you can see that the public ip of your ec2 instance if you refresh it the public ip of your ec2 instance has been just changed right it has to be mapped as an elastic ip with one of your elastic ip right so you are no longer able to you know ssh into your ec2 instance so what you can do is you can just open up a new powershell go to the place where the key is actually stored that is on desktop again go back to your ec2 instance click on connect and now this time the ssh ip has been changed to your elastic ip copy it and now you are into your ec2 instance so now what you have done you have actually been uh you know logged into your ec2 instance with the help of your elastic ip right so it's working fine right now the next thing what we have to do we have to actually create two different web pages over here so now i will be just switching again back to my super user and just changing my directory to html right so we will be actually changing ourselves to this particular directory so go to cd where www slash right and enter so you can see that now i am in this particular directory so now i will be creating another folder into it actually so my folder will be mkdir and the folder name will be web page 1 right and i will be going cd web page one creating a new folder and in this folder i will be making another web web page right so open bim index dot html just open a text editor and enter right and here i shall be clicking i so that i can be able to write over it this is just like your this is your vi editor actually so in order to write something you have to press i on your keyboard and you can see the uh you know this is in the insert mode right so here a html code written over here for my web page one so just copy it and paste it here right so uh just paste your data over here and switch your escape mode go to wq and enter right so now that is the thing we are going to do again with our the second page exit i think that will work right then again switch to sudo user su and now this time i have to again go to that html directory that was this right and now i will be creating one more folder in it by the name of html that is web page 2 right so i will be just actually making web page 2 directory again and this time i will be getting into web page 2 directory like like cd web page 2 right and here again i will be opening bim index dot html right clicking i so that i can get into the insert mode and this time changing this to 2 and just copy it again and paste it right and press escape to save colon wq and enter type exit so that you can get out of that particular uh you know directory right so uh what i have actually done over here is that i have created two different uh folders or two different directories in which i have created two different index.html pages right now going back to our management console and you can see that the public ip address of your ec2 instance has now been changed right so you can select any one of the elastic ip right open up a new url and just paste it over here and press enter and you can see that the apaches test page is working very fine now we will be checking that whether the two web pages that we have made are working fine or not so slash uh yes it is web page two so i will be just changing it to one first right so web page one slash index html enter and you can see that the web page one is working very fine and here i will be just checking the my second web page that is two whether it's working fine or not and yes it is also working very fine so this is our third step that we have created to different web pages on our apache web server right now our task is to associate one elastic ip with one web page and another elastic ip with the another test web page right for that what we have to do going back to our power shell and just i will be clearing each and everything and type exit so that we can get out of that particular mode yes right so now what i have to do over here i have to modify the httpd dot config file right so for that again the permission should be of super user right and i shall be going into the directory where the httpd underscore config file is there right so what i will be doing is i will be doing cd etc ht http and conf right and enter right and i will be doing ls minus l so that we can visualize that whether that file is there or not yes so what we are going to do over here is we will be modifying this httpd.conf file and here we will be mapping our elastic eyepiece with our web pages right so let me just open the file that is with the editor nano http dot conf or you can also open it in whim editor rather http d dot conf right and enter right so this is the file and find out where there is the virtual host tag right so the virtual host tag i am just searching it here it is so here is the virtual host tag over here right so press i so that you can actually insert your code over here this is the code with which we are going to map our private ip addresses to one of our web page that is the web page one right so i will be providing the uh you know this code in the description so that you can copy it from there and i have written ip addresses in two places over here right so what i have to do over here i have to mention one of my private ip address right that is this one which is mapped to this elastic rp address for my web page one right so copy your first private ip address right and paste it here and here right and then copy the whole code go back to your conf file and paste it over here right so you have pasted one of the private ip code over here right and now i have to do the same thing with the another ip address right so uh going back to my second notepad and here this will be for my web page 2 right so copy up one of your secondary private ip copy it here and go back to here change the ip in the two places one over here and second over here and everywhere where you have used web page 1 change it to 2 so everywhere where that was your web page 1 change that to 2 right so i have changed each and everything and i think it's working fine make sure it should not have any errors right so secondary ip secondary ip webpage 2 web page 2 web page 2 and correct so just copy it again go back to your conf file and just paste the second code also just check it once it should not have any errors right so here what we did we actually mapped our private ip addresses with our web page and here you can see that the private ip is mapped with this and this so you can assume that your elastic ip addresses are mapped to your you know web pages as transitive relationship right so going back to your conf file pressing escape colon wqn enter so now what you have done actually you have actually associated your uh you know private ips with your web pages right so before actually uh starting the you know your web pages with your ip address you have to stop and restart the httpd server so type system ctl http d right and then you have to start http d again http d and yes so you have actually did the particular thing that you have you have now associated your private ips with your elastic ip in turn with your web pages right so if i do you know remove this o from here and enter so you can see that with this elastic ip we are still able to visualize our web page one right and you can cross verify that with this 55 elastic ip1 we have associated our web page one now just copy the another elastic ip right go to the url and paste it here this is my second elastic ip and if i enter over here you can see that with the second elastic ip now i am able to visualize my web page too so with this particular thing we have completed the last step with which we have seen that how we can host multiple websites on a single ec2 instance i know that this hands-on was a little longer but i hope that it is somehow useful to you guys for more such videos stay tuned to my channel thank you
Info
Channel: Anjali Sharma
Views: 841
Rating: 4.8666668 out of 5
Keywords: #YouCut
Id: Wo0AlRNrFxY
Channel Id: undefined
Length: 28min 13sec (1693 seconds)
Published: Wed May 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.