EC2
Step 1: Connect to Your EC2 Instance
Use SSH to connect to your Amazon Linux EC2 instance. Replace your-instance-ip
with your instance's public IP address:
ssh -i your-key.pem ec2-user@your-instance-ip
Step 2: Update the Package Repository
It's a good practice to update the package repository to ensure you are installing the latest software packages:
sudo yum update -y
Step 3: Install Apache Web Server
Install the Apache web server with the following command:
sudo yum install httpd -y
Step 4: Start the Apache Service
Start the Apache service and enable it to start automatically on boot:
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
Step 5: Create the HTML File
You can use a text editor like nano
or vim
to create a simple HTML file. Here, we'll use nano
:
sudo nano /var/www/html/index.html
Add the following content to the index.html
file:
Save the file and exit the text editor (for nano
, press Ctrl + O
, then press Enter
, and then press Ctrl + X
to exit).
Step 6: Configure Security Group
Make sure that your EC2 instance's security group allows incoming traffic on port 80 (HTTP). You can do this in the AWS Management Console by modifying the security group associated with your EC2 instance.
Step 7: Access Your Web Page
You should now be able to access your web page by opening a web browser and entering your EC2 instance's public IP address in the address bar. You should see the "Happy Learning, Mr.CloudExplorer!" message displayed on the web page.
That's it! You've successfully set up a web server and created a simple HTML page on your Amazon Linux EC2 instance. You can further customize and expand your web application as needed.