Home Understanding the Fundamentals of Web Server
Post
Cancel

Understanding the Fundamentals of Web Server

Introduction

An HTTP web server is a software application that receives requests and sends responses using the Hypertext Transfer Protocol (HTTP). It is responsible for serving web content such as HTML pages, images, videos, and other resources to clients, typically web browsers like Google Chrome, Firefox, or Safari.

HTTP web servers typically listen on port 80 or 443 for incoming requests, and use the HTTP protocol to communicate with clients. They can serve static content directly from the file system or generate dynamic content by running scripts or applications.

Some popular HTTP web servers include Apache, Nginx, Microsoft IIS, and Caddy. These servers can be configured with various features such as SSL/TLS encryption, load balancing, caching, and more to optimize performance and security for web applications.

Apache Web Server

  1. First, we need the domain make sure to buy the domain name either from Godaddy.com or Google Domain Name.

  2. Create an A record in the DNS settings that points to the IP address of your server where Apache is installed.(I chosed Godaddy.com).

  3. Get the Public Ip from EC2 Instance by typing

    1
    
    curl ifconfig.me
    
  4. Install Apache web server on your server by running the following command

    1
    
    sudo apt-get update && sudo apt-get install apache2 -y
    
  5. Create a new virtual host configuration file for your domain. You can do this by creating a new file in the /etc/apache2/sites-available/ directory with a name like www.decodeai.in.conf

    1
    
    sudo nano /etc/apache2/sites-available/www.decodeai.in.conf
    
  6. Inside the file, add the following configuration:

    1
    2
    3
    4
    5
    6
    7
    
    <VirtualHost *:80>
        ServerName www.decodeai.in
        ServerAlias decodeai.in
        DocumentRoot /var/www/www.decodeai.in/public_html
        ErrorLog ${APACHE_LOG_DIR}/www.decodeai.in_error.log
        CustomLog ${APACHE_LOG_DIR}/www.decodeai.in_access.log combined
    </VirtualHost>
    
  7. Create the directory for your domain’s files:

    1
    
    sudo mkdir -p /var/www/www.decodeai.in/public_html
    
  8. Set the appropriate permissions for the directory:

    1
    2
    
    sudo chown -R www-data:www-data /var/www/www.decodeai.in/public_html
    sudo chmod -R 755 /var/www/www.decodeai.in
    
  9. Create an index file in the public_html directory to test the configuration:

    1
    
    sudo nano /var/www/www.decodeai.in/public_html/index.html
    

    Add some content to the file, such as “Hello World”.

  10. Enable the virtual host and restart Apache:

    1
    2
    
    sudo a2ensite www.decodeai.in.conf
    sudo systemctl restart apache2
    
  11. Finally, verify that your website is accessible through your domain name by opening a web browser and navigating to http://www.decodeai.in. You should see the content you added to the index file in the previous step.

That’s it! Your Apache web server is now configured to serve your website using your domain name www.decodeai.in.

Summary

An HTTP web server receives and sends responses using the HTTP protocol, serving web content to clients such as web browsers. It can serve static content directly or generate dynamic content by running scripts or applications. Popular HTTP web servers include Apache, Nginx, Microsoft IIS, and Caddy, with various features for performance and security optimization of web applications.

This post is licensed under CC BY 4.0 by the author.

DNS Explained - How Domain Name Server Work

TCP Connections - How Data Gets From Point A to Point B