{"id":3573,"date":"2023-02-06T18:02:23","date_gmt":"2023-02-06T18:02:23","guid":{"rendered":"https:\/\/exceedthecloud.com\/?p=3573"},"modified":"2023-02-11T11:38:13","modified_gmt":"2023-02-11T11:38:13","slug":"how-to-host-a-website-on-an-ec2-instance","status":"publish","type":"post","link":"https:\/\/exceedthecloud.com\/?p=3573","title":{"rendered":"How to Host a Website on an EC2 Instance"},"content":{"rendered":"\n<p>In this lab, you will host your first website on an EC2 instance. You will be using all the notions from previous labs to complete this lab successfully.<\/p>\n\n\n\n<p>Prerequisite: Having a valid AWS Account (Follow the step in this link to create an AWS Account) <a href=\"https:\/\/exceedthecloud.com\/?p=3419\" target=\"_blank\" rel=\"noreferrer noopener\">How to Sign Up for a new Amazon Web Services Account<\/a><\/p>\n\n\n\n<p>Open the page: <a href=\"https:\/\/aws.amazon.com\/account\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/aws.amazon.com\/account\/<\/a><\/p>\n\n\n\n<p>Create a security group to allow only port 80 and 22 to your EC2 instance<\/p>\n\n\n\n<p>Type VPC in the search box<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"473\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture1-7.png\" alt=\"\" class=\"wp-image-3574\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture1-7.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture1-7-300x227.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Select Security groups under Security menu<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"477\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture2-7.png\" alt=\"\" class=\"wp-image-3575\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture2-7.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture2-7-300x229.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Click on Create Security Group<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"86\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture3-7.png\" alt=\"\" class=\"wp-image-3576\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture3-7.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture3-7-300x41.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Enter the Security group name<\/p>\n\n\n\n<p>Add the rule for SSH and HTTP in the inbound rules \/ Click Create security group<\/p>\n\n\n\n<p>SSH allowed only from my IP address and HTTP from anywhere<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"402\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture4-7.png\" alt=\"\" class=\"wp-image-3577\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture4-7.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture4-7-300x193.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Launch our EC2 instance<\/p>\n\n\n\n<p>Type EC2 in the search box<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"551\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture5-6.png\" alt=\"\" class=\"wp-image-3578\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture5-6.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture5-6-300x265.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Click on Launch instance<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"484\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture6-6.png\" alt=\"\" class=\"wp-image-3579\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture6-6.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture6-6-300x233.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Enter your instance name \/ Select Amazon Machine Image \/ Instance type \/ Key pair \/ Security group and storage \/ review and click on Launch instance<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"462\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture7-6.png\" alt=\"\" class=\"wp-image-3580\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture7-6.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture7-6-300x222.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Confirm that the instance is up and running <\/p>\n\n\n\n<p>Note the public IPv4 address, you will need it for the next task<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"320\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture8-5.png\" alt=\"\" class=\"wp-image-3581\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture8-5.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture8-5-300x154.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/exceedthecloud.com\/?p=3550\" target=\"_blank\" rel=\"noreferrer noopener\">Connect to your EC2 instance with SSH client PuTTY<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ec2-user@X.X.X.X(your IP v4 address)<\/code><\/pre>\n\n\n\n<p>Enter the IP and Key pair in PuTTY client \/ Click Open<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"436\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture9-5.png\" alt=\"\" class=\"wp-image-3582\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture9-5.png 449w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture9-5-300x291.png 300w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/figure>\n\n\n\n<p>Click on Yes to add the key to PuTTY&#8217;s cache and trust the host<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"362\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture10-5.png\" alt=\"\" class=\"wp-image-3583\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture10-5.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture10-5-300x174.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Confirm you are connected to the EC2 instance with SSH<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"395\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture11-5.png\" alt=\"\" class=\"wp-image-3584\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture11-5.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture11-5-300x190.png 300w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture11-5-80x50.png 80w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Install all the software needed by our website<\/p>\n\n\n\n<p>Run the commands bellow<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su\nyum update -y\nyum install -y httpd\ncd \/var\/www\/html\nwget https:\/\/github.com\/marcelin-ndjila\/webtemplate\/archive\/refs\/heads\/main.zip\nunzip main.zip\ncp -r webtemplate-main\/* \/var\/www\/html\nrm -rf webtemplate-main main.zip\nsystemctl enable httpd\nsystemctl start httpd\n<\/code><\/pre>\n\n\n\n<p>Confirm your have access to the new website by entering the public IP address of your EC2 instance in a browser<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"326\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture12-3.png\" alt=\"\" class=\"wp-image-3585\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture12-3.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture12-3-300x157.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Clean up your lab and terminate your EC2 instance<\/p>\n\n\n\n<p>Type and select EC2 in the search bar<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"556\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture13-2.png\" alt=\"\" class=\"wp-image-3586\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture13-2.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture13-2-300x267.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Select Instances in the menu<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"417\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture14-3.png\" alt=\"\" class=\"wp-image-3588\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture14-3.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture14-3-300x200.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Select the instance and click on terminate instance<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"320\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture15-2.png\" alt=\"\" class=\"wp-image-3589\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture15-2.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture15-2-300x154.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Click on Terminate<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"294\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture16-1.png\" alt=\"\" class=\"wp-image-3590\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture16-1.png 537w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture16-1-300x164.png 300w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<p>Confirm the instance is terminated<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"100\" src=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture17-1.png\" alt=\"\" class=\"wp-image-3591\" srcset=\"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture17-1.png 624w, https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/Picture17-1-300x48.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Credit: <em><a href=\"https:\/\/www.aosnote.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Azeez<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this lab, you will host your first website on an EC2 instance. You will be using all the notions from previous labs to complete this lab successfully. Prerequisite: Having a valid AWS Account (Follow the step in this link &hellip; <a href=\"https:\/\/exceedthecloud.com\/?p=3573\">Continued<\/a><\/p>\n","protected":false},"author":1,"featured_media":3592,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"kt_blocks_editor_width":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[121,118,123,26],"tags":[119,120,130,131],"class_list":["post-3573","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-amazon-web-services","category-aws","category-aws-basics","category-web","tag-aws","tag-aws-account","tag-ec2","tag-website"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/exceedthecloud.com\/wp-content\/uploads\/2023\/02\/hosting1.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/posts\/3573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3573"}],"version-history":[{"count":10,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/posts\/3573\/revisions"}],"predecessor-version":[{"id":3714,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/posts\/3573\/revisions\/3714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=\/wp\/v2\/media\/3592"}],"wp:attachment":[{"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/exceedthecloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}