Hosting Apache Webserver with a simple webpage in AWS instance

·

2 min read

To perform the below task you have to do the following :

  1. Create an AWS account.

  2. Launch Amazon Linux from Ec2 Instance and then log in to that instance.

  3. Copy the public IP for further use.

  4. Login to your root account using the command sudo -su root

To provide and access web services we have two steps respectively

  1. Configure/Setup a server

  2. Configure/Setup a client

    Steps for configuring a server :

      1. Install the software where you will provide your web services.

        here we will use Apache webserver. first, you can check whether you have already installed the software using rpm -q httpd , if not installed you can install it using yum install httpd

  1. Setup the requirement of the server

    In my case, I'm just creating a simple webpage. To do so we have the following steps

    • create your webpage using the following command vim anu.html

    • enter the content and save, to view the content you can use the cat command, cat anu.html

  • After saving, copy that to the following folder /var/www/html, the command for copying the file is cp anu.html /var/www/html

    1. Hosting the webpage /Starting the services
  • to start the services the following command is used

    systemctl start httpd

  • to check whether it is active or not you can check using the command systemctl status httpd

  • After successfully hosting the server, Now you can set up the client

Steps for configuring a client:

    1. Install a web client software

      • for GUI you can install Firefox or any other software to access the website. the command to install Firefox is

        yum install firefox

      • for CLI you can use the curl command curl http://<ipaddress>/<wbpgname

      1. Connect to the server

        • To connect to the server, the client should know the IP protocol and the service.

        • To connect you have to form a URL

          http://16.171.154.80/anu.html

          <protocol>/<public ip>/<webpagename>

  • Sometimes while connecting issues related to the firewall can arise.

  • In such a scenario, you can check your firewall status and stop it using the following command

    systemctl status firewalld

    systemctl stop firewalld

Thank you!