Making an Apache Web Server using AWS EC2 CentOS Server

Ronald Easley
4 min readJul 9, 2023

--

Step-by-step guide

Step 1 : Type aws.amazon.com into your web browser.

Step 2: Log into you account.

Step 3: In the search bar type EC2

Step 4: Click the icon for Amazon Ec2 console

Step 5: Click Launch Instance

Step 6: Set instance name remember it needs to be globally unique.

Step 7: Scroll down to “Application and OS Images” (Amazon Machine Image) look to the of right of the pages there is an option at “Browse more AMIs” click the magnifying glass.

Step 8: When the page has loaded look below the search bar and click on the “Aws Marketplace AMIs”. Once page is loaded type CentOS in the search bar.

Step 9: Look for “CentOs 8 with Support by Supported Images”. Look below and the option should appear ,click the select button to the right. A screen will pop-up click continue button

Step 10: When the page is loaded ,scroll down to Instance type select “t2.micro” you’ll see that its “Free tier eligible” meaning up to specified limits this instance is free for 12 months!

Step 11 : Next you need to either use an existing keypair or create a new keypair for this instance .

Step 12 : Scroll down to “Network settings” skip down to “Firewall (security groups)” you’re going to create a new security group. Scroll down to the “Inbound Security Rules” click on the “Add security group rule”.

Step 13 : Make the Type “HTTP” and set the Source type to “Custom” and the Source should be set to “0.0.0.0/0”. Set the “ssh” rule option Source type to “Custom” and the Source to “0.0.0.0/0”. Now set the Outbound Rule Source “All traffic” and set the Source type to “0.0.0.0/0”. Afterwards click launch button.

Step 14 : Click the “instance” option to the left of the page. Find your instance you just created. Once its up and running you are going to click on the instance and then click connect button to the upper right of the page.

Step 15 : Using the “ssh” option connect to your instance by opening power shell(Windows users)/ Terminal Line(MAC users). MAC users will have to use the “chmod 400” command to ensure your key is not publicly viewable. Then copy and paste “ssh” command into terminal. Windows users open Power shell. Then access your key from where it is saved by running “ls + file directory command”( The file directory is where the keypair automatically saved to when it was created such as Documents, Desktop etc.) then copy and paste “ssh command” make sure to change user name to “centos” in the “ssh” code ex: (ssh -i “DuitCentOs_Instance23.pem”centos@ec2–3–83–160–210.compute-1.amazonaws.com)

from your EC2 instance into the next line. It will ask for permission. Proceed by coding “yes” then hit enter key on keyboard.

Step 16 : Next you will code “sudo yum update” if you are using the root account you can omit “sudo” part of code and just run “ yum update”.

Step 17: Once update is finished on the next code line run the Apache install code “sudo yum -y install httpd”

Step 18: On the next line run Apache start code “ sudo systemctl start httpd”

Step 19 : Optional if you want Apache to startup automatically code “sudo systemctl enable httpd”

Step 20: Next you want to check the status of your Apache web server by coding “sudo systemctyl status httpd”.

Once you see its running go back to your instance in the EC2 console and copy and paste your “public ip address” in the web browser. Your Apache web page should appear confirming your success!

--

--