Skip to main content

Run Website on AWS EC2

You may need to learn how to run your website without any help from others. Here is a way to do this.

What you need.
  • AWS Account ( you can register for Free Tier account)
Initial Plan

Firstly, I will create an AWS S3 Bucket for uploading the web content. In order to copy the content of the S3 to EC2, I need to create IAM role with s3 full access permission. Then  I will launch an AWS EC2 instance and configure the EC2 instance to run my website.

This is very simple. Let's Start.

Steps 1: Create S3 bucket

Go to services and select the S3



Create a bucket






Now click the create button



I have downloaded the basic HTML template website for this blog. you can simply upload your web content to the S3 bucket. Here I have a zip file.

click the newly created bucket and select the web content to upload




Click the upload button


Ok, now we have our web content on the S3 bucket. Let's create an IAM role with s3 full access permission.

Step 2: Create IAM Role

Now go to Security, Identity & Compliance under service and select IAM



Click the create role button



Select EC2 and click on Next:Permission





select the AmazonS3FullAccess



Click the Next:Tag 


Then Review and create the role




You have created the role. 


Step 3: Create EC2 Instance

Now we need to launch the EC2 instance. Go to Compute under Services and select EC2.








keep step 3 Configure Instance Detail and Step 4 : Add Storage Step 5: Add Tags as default



Click Review and Launch and then click launch. 



Select "create a new key pair" from the drop-down menu and name your key and hit the download key pairs and Launch the Instances. Now go to EC2 and select the instance you just create.

Select the Attach/Replace IAM role under Action


Select the Role that You Created earlier and apply.



copy the IP address and ssh to the EC2 instance using the below command in linux.




ssh -i ~/.ssh/mykey.pem ec2-user@ec2-18-232-95-17.compute-1.amazonaws.com


Now you need to install a server in order to run my website. So I have to install the relevant server using below commands

sudo su
yum install httpd -y
Now I need to download the zip file from my s3 bucket.

aws s3 cp s3://harshana-website-demo/myWeb.zip /var/www/html
Unzip the zip file 
unzip myWeb.zip
Now, I need to start the httpd server 
service httpd start
Ok, we are done.

Open the browser and go to this link  http://<ip address>/myWeb/









Comments

Popular posts from this blog

Understanding C1 and C2 Compilers in Java

Understanding C1 and C2 Compilers in Java Understanding C1 and C2 Compilers in Java In Java, the Just-In-Time (JIT) compiler is a part of the Java Virtual Machine (JVM) that improves the performance of Java applications by compiling bytecode into native machine code at runtime. The JIT compiler includes two different compilers, known as the C1 and C2 compilers, each with distinct optimization strategies and purposes. C1 Compiler (Client Compiler) The C1 compiler, also known as the client compiler, is designed for fast startup times and lower memory consumption. It performs lighter and quicker optimizations, which makes it suitable for applications that require quick startup and responsiveness. Key characteristics of the C1 compiler include: Quick Compilation: Prioritizes fast compilation times over deep optimizations. Low Overhead: Consumes less memory and resources during compilation. Profile-Guided Optimization: Ca...

Understanding -XX:+PrintCompilation Output in Java

Understanding -XX:+PrintCompilation Output in Java Understanding -XX:+PrintCompilation Output in Java The -XX:+PrintCompilation flag in the Java Virtual Machine (JVM) prints information about the methods being compiled by the Just-In-Time (JIT) compiler. When you enable this flag, the JVM will output a log of compilation events to the standard output. Each line of the output provides information about a specific method being compiled. Here, I'll explain the meaning of the different columns and markers, specifically focusing on the n , s , and % markers as seen in your example. Explanation of Output Columns and Markers Here's a breakdown of what each column and marker means: Timestamp : The time (in milliseconds) since the JVM started when the compilation event occurred. Compilation ID : A unique identifier for each compilation task within the JVM's lifecycle. Optimization Level : The lev...

What is L1, L2 and L3 Support Engineering

In this blog article, I'm going to explain about the Software support engineering role with my experience. I was a Level 2 and 3 support Engineer during my career. L1 - Level 1 L2 - Level 2 L3 - Level 3 Ticket - Incident L1 support includes interacting with customers, understand their issue and create tickets against it. The ticket then routed to the relevant L2 support ( Integration support, Server & Storage support, etc ...). L1 support Engineers have basic knowledge of product/service and skill to troubleshoot a very basic issue like password reset, software installation/uninstallation/reinstallation. L2 support manages the tickets which routed to them by L1( L2 support also can create tickets against any issue notice by them). They have more knowledge, more experience in solving related complex issues and can guide/help L1 support folks job in troubleshooting. If the solution not provided at this level then escalate to the L3. L3 is ...