DEV Community

Santhosh V
Santhosh V

Posted on

CA 28 - Create a simple EC2 instance and run a webserver and access it from outside.

Today I tried creating a small server in AWS and accessed it from my browser. It’s actually very simple.

First, I went to AWS and opened EC2. Then I clicked “Launch Instance”. I gave it a name, selected Amazon Linux, and chose a small free-tier instance.

Next, I created a key pair (this is important for login) and downloaded it. Then in network settings, I allowed HTTP (port 80) so I can access the website from outside.

After that, I launched the instance.

Once it started running, I connected to it using SSH. After logging in, I installed a web server using this

Once it started running, I connected to it using SSH. After logging in, I installed a web server using this command:

sudo yum install httpd -y
Enter fullscreen mode Exit fullscreen mode

Then I started the server:

sudo systemctl start httpd
Enter fullscreen mode Exit fullscreen mode

I also enabled it so it runs always:

sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

Then I created a simple webpage:

echo "Hello from my EC2 server" | sudo tee /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Top comments (0)