How to Setup an Apache Web Server with AWS EC2 Instance 2020

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys this is Trojan cookie protocol and in this video I'll be showing you how to set up an Apache web server with AWS the agenda is I'm going to be talking about how to set up the network from regions to availability zones I'm going to show you how to configure and launch an ec2 instance then setting up the Apache web server and then some of the next steps like connecting to a database or creating an API so to begin with a region is a geographical area which consists of availability zones and an availability zone is an area within a region that consists of multiple data centers so on the diagram it illustrates that you have this region and within that region you can have several availability zones and within availability zones you will have data centers which is where your server where your instant is being hosted on and AWS has four regions north america south america and then they seem to couple Europe Middle East and Africa and then you have Asia Pacific now we're going to set up and configure our network first you want to go to aws.amazon.com and if you haven't created an account already create an account and once you have done so sign into the console here is an illustration of a region and availability zone and within this region we have something called a virtual private cloud and a virtual private cloud is a logically isolated virtual network that lets you launch AWS resources and you have complete control over an IP address range and it allows you to create subnets and configure your route tables and this is what we're going to set up first things first you want to select your region so if you go on the top right hand corner select your region or location so I'm in London and then after that this is our management console so it's going to show all of the services available to us that AWS provides so if we click on the services tab and as you can see AWS has loads of services that it provides which is really useful if we type in V PC and select V PC then this is our dashboard if we click V PC all I prefer the V PC there under region and if we create V PC we enter our name tag so we'll call it web server we select a CIDR block if you're not familiar with CIDR then I highly recommend that you do some research into it and then we just click create and that's our V PC done at this point we've created our V PC within a region we need to now create a subnet and a subnet is just a logical subdivision of an IP network in this case it's a logical subdivision of our V PC here are some illustrations of what I mean so on the left hand side we have a region and a V PC inside that region and the V PC can be spread across multiple availability zones and this is because it increases resilience in case one of the availability zones happens to be down your systems will still be running and on the right hand side this is just a detailed illustration of what I've just explained with with IP addresses as established and linked and explained what of what else have we got yep with three subnets within a V PC again you can have them as many subnets as you'd like as long as within appropriate range of your V PC let's create our subnet then by going to subnets just under your V pcs we click create subnet we enter our name tags so in this case we'll call it web server subnet we select the previously created V PC which was web server V PC we select our availability zone so let's just select e west to a and then we type in our CIDR block and then click create and that's your subnet created so we have our region selected our V PC created and we've also created a subnet now we need to create a security group to manage our inbound and outbound traffic so if we scroll down and go to security groups and it will show the default security group already there and if we select create security group write a security group name in this case it will be webserver SG and we'll write a simple description followed by the V PC we created earlier and if we just click create that's our security group created however we need to set inbound and outbound rules for traffic to access our website and our instances that will be running so if we go to inbound rules and edit those rules we can control the incoming traffic that's allowed to reach the instance so if we add rule we select a rule and it's going to be HTTP select HTTP and under source we're going to select anywhere which means anyone can access this website at the same time we are going to add another all SSH to log into our server to connect to our server for just the convenience of this video I'm going to click anywhere but you definitely want to select my IP as a safety precaution and then if we just click create and those are your inbound rules configured and here you can see all of your rules your inbound and outbound rules under this section here now we are ready to launch our ec2 instance ec2 stands for elastic cloud compute and essentially it's just a service that helps you set up your computing environment and all security scalability control and you initialize ec2 instances so again this is an overview of what we've done so far and the ec2 instance is going to be located in our subnet that we've created with the security group in place now we're going to create our security sorry ec2 instance we're going to go to services under compute we're going to click easy-to we're then going to launch instance or go to our running instances I've already got an instance terminated there so don't worry about that and we're going to just click Launch instance now we're going to set and choose our Amazon machine image I'm going to select the second one which is from the free tier eligible scheme so if we click select on that then we are going to choose our instance types such as the CPUs and memory and type of storage generally you don't need to configure most of this it's already pre-configured and so if we just click Next the most important part would be this part it's selecting our network subnet and IP so we under Network we will select our V PC the subnet that we want our ec2 instance to be running in and to auto assign our instance an IP address so if we enable Matt and leave the rest as it is and click Next so here you can increase or decrease your storage but we're going to go next we can click Next here as well and now we are going to attach our security group that we previously created so we select an existing security group we select web server security group the one that we created and we can see our rules there we review and we can dismiss anything and just click Next and and create remember to download your key pair in order to access your ec2 instance so it's a private key that's going to be downloaded so we're going to create a new key pair we're going to type in a key pair name in this case it's just going to be web server and click download and save it to your desktop are that's right I've already got a key pair named web server so I'm going to rename it something else but in the meantime you can download this key pair and save it to your desktop then launch instance your instance has now been launched and you can take a look at your running instance it may take a while to setup and initialize maybe a couple of minutes before we move on we would like a public dns name domain name as you can see here we don't actually have one we just have a public IP and to enable this we go to V PC or you could just type V PC and we select V PC and we select our created V PC that's the third time I've said V PC but then we go to actions and click Edit DNS host names and we just a name or DNS host names and continue and that should update that and if we go back to our ec2 instance we should find that we have a public domain name instead of just the IP and narratives now we want to connect to the server and we can do this through a terminal the terminal I like to use is provided by a gift so if you go to the website get four windows and you download the terminal that's offered there then this is what I'm going to be using and you can continue with that alternatively there is a program called putty if you go to their website download putty open it up click Next and just follow the installation process it's really simple this is just an alternative if you prefer to use one or the other or you're on a Linux system that's perfectly fine except any messages that may occur and click finish if you're on putty you will need to do some extra configuration so if you search for puttygen or putty generator and you click load and then you open the key file that you downloaded on your onto your desktop you open it up it will say it's been imported then you want to save your private key just click yes and then save it onto your desktop again so you're saving it onto your desktop now this was step one the second step is actually using this key to connect to our server so now open the party application what we're going to do is we're going to copy our public DNS and we're going to paste it into host name then we're going to go to SSH right there we're going to expand that we're going to click on earth and we're going to browse for the file that we just generated our private key file and if we go back to session and we open now the default user is easy to user - user and then you should be able to connect now no you won't actually be able to connect immediately because of an issue that I will explain later on but we should now be on the same track so what we're going to want to do is attempt to connect and the connection won't work and it's because we don't have an internet gateway setup so remember remember back to the diagram I was showing you guys we had our VBC we had our subnets we had our security group and we had our ec2 instance however we didn't have any mechanism to actually connect to the internet and in order to do this we need something called an Internet gateway so what you're seeing now is an attempt to connect to these webserver but this connection will be refused because there isn't a way for us to connect to it so here is the illustration we have no Internet gateway and any connections are able to connect to the security group the sorry the ec2 instance for the ec2 instance has no way of responding back because there just isn't a way for it there are there are no routes set up so what we need to do is enable an Internet gateway such that the ec2 instance can actually respond to us and connect it to the Internet and this is what we are going to set up so go to services under services click VPC first we want to create our internet gateway so we're going to create our Internet gateway we are going to name it a web server Internet Gateway click create close that we can see that it is detached so we want to attach it so under actions click attach to V PC and select the V PC that you created earlier on and then just click attach the next step is to come I'm just going to show you what the subnets look like now and if we take a look at our root table we see that there is only one root but in essence we need two roots therefore we must configure this so and we can figure this by setting up a root table so let's click great root table let's name it web server root table and attach it to the V PC click create close that so we have our root table configured now we can take a look at the roots we edit the root now let's add a root and we going to add a root such that it is from the ec2 instance to the Internet gateway that we created and we select the internet gateway that we've created and now we save the roots close that we now want to further configure this we see we have our internet gateway we have our root tables set up or our root table set up with the two roots within it and now on subnets if we go to subnets and we click on root table we edit root table Association and we're going to select a new root table the root table that we just created and we click web server root table and there you can see we have our two roots one for traffic coming in and another route for the ec2 instance to respond through the internet gateway now we'll just close this and we are going to connect to our web server again now that the internet gateway is set up so you can do the three party I'm going to do it through here and just type in yes if you get this response and now you have successfully connected to your web server and so the next step is to configure our web server by installing Apache and PHP and user groups so if we navigate to this link which I'll leave in the description we are going to install the apache software and there are numerous commands that we must run is shown here so we're going to do everything up to that section as you can see the commands include updating the system it includes installing Apache web server with PHP and later on it will include configuring groups and users such that the system will be set up for when you when you when you run it and when you visit the default site so if you just navigate to this website just copy and paste the commands if you don't understand the Kwan's I would really recommend you take some time to understand what they are executing as they can be quite useful in the long run especially if you're going to run multiple instances in the future apart from this one so this one will start the Apache web server and the following command will actually start the server on each boot and there should be some descriptions alongside these commands to help you understand what they are doing and but you can do this in your own time it's just again copying and pasting with this command we exit out and then connect back in so that was the last command to to run and now if we grab the Public DNS we copy that and we paste that into our input and search bar we can see that the web server is in fact running and the test page is now configured now if you connect to your web server using your favorite IDE and you navigate under HTML folder and you create a new file let's name this index.html and just write something under that under in the index or HTML file you can write anything you like we're just going to make sure that we can actually create a webpage a HTML document and that it's going to be displayed publicly on our web server so now go back to your browser again copy and paste your Public DNS put it into the search bar and you should receive whatever you've written and that's it in sum we selected eight region we created a V PC and a subnet within that V PC we created a security group and then launched an easy-to instance within that V PC we also configured inbound and outbound connections followed by creating an Internet gateway such that the ec2 instance could actually respond to us so that was the end of the video I hope it was of use to you and some next videos might be connecting to a database or SSA Qing into your web server using Visual Studio code or perhaps even actually setting up WordPress with AWS but that's it from me I hope you enjoyed this video if you did give it a like comment and subscribe and I'll see you in the next video
Info
Channel: Trojan Cookie Protocol
Views: 17,816
Rating: undefined out of 5
Keywords: aws, server, instance, apacher, setup, tutorial, trojan, cookie, protocol, tcp, trojancookieprotocol, ec2, php, walkthrough, new, 2020, simple, easy, ssh, vpc, subnet, securitygroup, network, ip, cidr, git, windows, linux, command, terminal, vsc, mysql, html, web, webserver, programming, igw, internetgateway, subscribe, like, comment, youtube, ipaddress, address, hosting, domain, website, wordpress, api, nginx, apache
Id: AS3JNoXDHZI
Channel Id: undefined
Length: 21min 15sec (1275 seconds)
Published: Sun Dec 01 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.