🖥️ Web Servers

What is a web server? Learn about Apache and Nginx — the two most popular web servers powering the internet.

🌍 Web Server Fundamentals
Q1What is a web server?Beginner

A web server is software (or the hardware running it) that serves web pages to users. When you type a URL in your browser, your browser sends an HTTP request to the web server, which responds by sending back the requested HTML, CSS, JS, images, etc.

The most popular web servers are Apache and Nginx. Together they power over 50% of all websites.

💡 Even cheap shared hosting runs a web server (usually Apache). You don't need to configure it yourself — your hosting provider handles it.
Q2What is the difference between Apache and Nginx?Intermediate

Both Apache and Nginx are popular open-source web servers, but they work differently:

  • Apache — Launched 1995. Process-based model (one thread per request). Great compatibility, uses .htaccess files for config per-directory. Default on most shared hosting.
  • Nginx (pronounced "engine-x") — Launched 2004. Event-driven, asynchronous model. Handles thousands of concurrent connections efficiently. Often used as a reverse proxy or load balancer.

In practice: Nginx is faster for serving static files and under high load. Apache is more flexible and easier to configure per-directory. Many servers use both — Nginx as reverse proxy, Apache as backend.

⚠️ As a beginner on shared hosting, you won't need to choose — your host provides Apache. This only matters when you manage your own VPS.
Q3What is an .htaccess file?Intermediate

An .htaccess file is a configuration file used by Apache web servers. It lets you control server behaviour for a specific directory without editing the main server config.

Common uses:

  • Redirecting URLs (e.g. redirect HTTP to HTTPS)
  • Custom 404 error pages
  • Password-protecting directories
  • Blocking specific IP addresses
  • Enabling URL rewriting (pretty URLs)
# Redirect HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
💡 The dot at the start (.htaccess) makes it a hidden file on Linux. Use your FTP client's "show hidden files" option to see it.