Training Guide

Web Server Configuration

Apache & Nginx — how requests get routed, how virtual hosts work, and what to check first when a site goes down.

Apache Nginx PHP-FPM 10 slides
1.1

What a web server actually does

A web server is software that listens for HTTP/HTTPS requests on a port (usually 80 or 443) and responds with content — an HTML page, an image, or a signal to hand the request off to something else. At its simplest, it maps an incoming request to a file on disk and sends that file back.

"Configuration" is how we tell that generic program what to actually do for our specific site: which domain it should answer for, where the files live, how to handle errors, whether to compress responses, how long to cache things. Without configuration, a web server has no idea whose website it's serving, or how.

Diagram: a web server acts like a waiter, either serving static files directly or passing the order to an application server (kitchen) for dynamic content.
1.2

Why configuration matters, day to day

1.3

Key terms you'll see throughout

TermWhat it means
Web serverSoftware that handles HTTP requests and serves static content (Apache, Nginx, LiteSpeed).
App serverSoftware that runs your site's actual logic — PHP, Node.js, Python — and talks to the database.
Virtual hostA configuration section telling the web server how to handle requests for one specific domain.
Reverse proxyA web server that forwards requests to another server (often an application server) instead of answering them directly.
DirectiveA single configuration instruction, e.g. ServerName or listen.
02

Web server vs. application server

A web server handles client requests for static content and basic HTTP functionality. An application server handles business logic, processes requests, and talks to databases and external systems. Think of the web server as the receptionist — it either answers directly with static content, or forwards the request to the right department.

Common web servers

  • ·Apache — most popular, flexible. On Hostinger: VPS only.
  • ·Nginx — fast, handles high traffic well. Agency plan & VPS.
  • ·LiteSpeed — high performance, WordPress-optimized. Shared & Cloud.

Common application servers

  • ·PHP-FPM — processes PHP code (WordPress, custom PHP sites).
  • ·Node.js — runs JavaScript server-side.
  • ·Python / Django — Python-based web apps.
  • ·Java app servers — enterprise applications.
Why it matters: slow static content points to the web server; slow dynamic pages point to the app server or database. 500 errors usually come from the app server; 404s usually come from the web server.
03

Virtual hosts: routing many sites through one server

A single server can host many websites on one IP address. Apache calls this a "virtual host"; Nginx calls it a "server block." Either way, the mechanism is the same: the browser sends a request with a Host header, the web server checks its configured hosts for a match, and serves that site's files.

PanelWeb server used
cPanelApache (port 2087)
FastPanelNginx (port 8888)
HestiaCPNginx (port 8083)
CyberPanelOpenLiteSpeed (port 8090)
Diagram: one physical server hosting example.com and shop.com, with the web server reading the Host header to route each visitor to the matching site folder.
4.1

Setting up a virtual host — Apache

Main config: /etc/apache2/apache2.conf (or httpd.conf). Individual sites are usually split into their own files under sites-available/.

<VirtualHost *:80> ServerName example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example_error.log CustomLog ${APACHE_LOG_DIR}/example_access.log combined </VirtualHost>
  1. 1. Save in sites-available/example.com.conf
  2. 2. Enable it: a2ensite example.com.conf
  3. 3. Test the config: apachectl configtest
  4. 4. Reload: systemctl reload apache2
Apache also supports .htaccess files, read dynamically on every request — used for redirects, rewrites, password protection, caching, IP blocking, and WordPress permalinks. This only works because Apache is configured to allow it, which is a key difference from Nginx.
4.2

Setting up a virtual host — Nginx

Nginx does not use .htaccess. All configuration is centralized, usually at /etc/nginx/nginx.conf, sites-available/, and sites-enabled/.

server { listen 80; server_name example.com; root /var/www/example.com/public_html; location / { try_files $uri $uri/ =404; } }
  1. 1. Save as sites-available/example.com
  2. 2. Symlink into sites-enabled/
  3. 3. Test the config: nginx -t
  4. 4. Reload: systemctl reload nginx
Because Nginx ignores .htaccess entirely, a redirect that works fine on Apache/LiteSpeed shared hosting can silently do nothing on an Nginx-based VPS panel — one of the most common sources of confused tickets.
05

Troubleshooting common issues

5.1 Apache

Service stopped typically shows as: site offline, connection refused, or Apache failed errors. Common causes: broken config, port conflict, syntax errors, high resource usage.

systemctl status apache2 sudo systemctl restart apache2 sudo apachectl configtest

5.2 Nginx

SymptomLikely cause
502 Bad GatewayPHP-FPM stopped, or backend unavailable
504 TimeoutSlow app, overloaded server, hanging PHP process
Port conflictApache and Nginx both on port 80
systemctl status nginx sudo systemctl restart nginx sudo nginx -t
5.3 — 5.4

What we check at the infrastructure level

On VPS, Hostinger supports infrastructure availability, but server management belongs to the client — it's worth being clear with customers about where that line sits.

⚠ Golden rule: always test a config before reloading it — apachectl configtest or nginx -t. A bad reload can take the whole server down.
Use or space to navigate