Now that we know how to create a Linux EC2 instance in the AWS Cloud and access the same, we will create a simple static web site on the same.
1. When we created a Security Group, the port 22 was opened. This will enable the access to the remote machine. But, a WebServer listens to port 80 and the same has to be opened.
2. Select the Security Group and click on the Inbound tab.
3. Click on Edit and the rule for the HTTP inbound traffic as shown below.
Now, the Security Group rules should appear like this.
8. Open the same in the browser to get the web page as shown below.
1. When we created a Security Group, the port 22 was opened. This will enable the access to the remote machine. But, a WebServer listens to port 80 and the same has to be opened.
2. Select the Security Group and click on the Inbound tab.
3. Click on Edit and the rule for the HTTP inbound traffic as shown below.
Now, the Security Group rules should appear like this.
Note that if the Linux or the Windows instance is running, then any changes to the Security Group will take place immediately. There is no need to restart the EC2 instance.
4. The best practice is to update the package on the Linux instance with the `sudo yum update -y`. When prompted select yes.
5. Install the WebServer and start it. The first command to elevate the user to root, the second command will install the WebServer and the final one will start the same.
sudo su yum install -y httpd service httpd start
The WebServer won't start automatically, if the Linux instance is rebooted. If it has to be started automatically on boot/reboot use the below command
chkconfig httpd on
6. Go to the /var/www/html folder and create an index.html file using the below commands
cd /var/www/html echo "Welcome to thecloudavenue.com" > index.html
7. Get the ip address of the Linux instance from the EC2 management console.
The above sequence of steps will simply install a WebServer on the Linux instance and put a simple web page in it. Much more interesting things can be done. One thing to note is that all the above commands were executed as root, which is not a really good a good practice, but was done for the sake of simplicity.
No comments:
Post a Comment