What is NGINX?
NGINX is a web server, reverse proxy and load balancer built to hold tens of thousands of open connections with very little memory. It fronts a large share of the busiest sites on the internet.
What problem was NGINX designed to solve?
It was written to serve many simultaneous clients without one process or thread per connection. Older servers that dedicated a worker to each visitor ran out of memory when thousands of slow mobile clients connected at once. NGINX instead runs a small number of worker processes, each with an event loop that watches thousands of sockets through epoll on Linux and handles whichever one is ready. A single worker can juggle a huge number of idle keep-alive connections for a few kilobytes each.
What is NGINX used for?
Four jobs cover most installations, and one instance often does all of them at once:
- Serving static files such as images, scripts and downloads straight from disk, using sendfile to avoid copying data through user space.
- Reverse proxying requests to application servers: PHP-FPM, Node.js, Python with Gunicorn, Java services or anything speaking HTTP or FastCGI.
- Terminating TLS so the application behind it only sees plain HTTP on the loopback interface.
- Balancing load across several upstream processes or machines, with health-aware retries.
How is a configuration organised?
In nested blocks. The http block holds global web settings, each server block describes one site by its listen port and server names, and location blocks inside it decide how matching paths are handled. On Debian and Ubuntu, site files live in /etc/nginx/sites-available and are enabled by a symlink; on AlmaLinux, Rocky and Fedora, drop them in /etc/nginx/conf.d. A compact site that serves files and hands PHP to FPM looks like this:
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name shop.example.net;
root /srv/shop/public;
ssl_certificate /etc/letsencrypt/live/shop.example.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/shop.example.net/privkey.pem;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9083; # pool listening on a loopback port
}
}
Test before every reload with nginx -t, then apply with systemctl reload nginx; a reload swaps workers gracefully without dropping open connections.
How does NGINX compare with Apache?
Both are excellent; they make different trade-offs. Apache with the event MPM is close to NGINX in raw throughput today and still offers per-directory .htaccess overrides, which shared hosting panels rely on. NGINX has no per-directory files, so every rule lives in the main configuration, which is faster and easier to audit on a server you control alone. A common pattern on a dedicated machine is NGINX in front for TLS, static files and caching, with the application server behind it. Our Install a LAMP stack guide shows the Apache route if your software expects it.
How should workers be tuned on a many-core server?
Let NGINX match the hardware and raise the file limits. With worker_processes auto it starts one worker per logical CPU, so ESSENTIAL-M with 12 runs that many event loops. Each connection uses a file descriptor, and a proxied request uses two, so raise worker_rlimit_nofile and the systemd LimitNOFILE together:
worker_processes auto;
worker_rlimit_nofile 131072;
events { worker_connections 16384; multi_accept on; }
Twenty-four workers at 16,384 connections each could in theory hold about 390,000 sockets, far above what one 1 Gbps port will carry for real traffic, so the network rather than NGINX becomes the ceiling. Machines on the Business line line start at a 3 Gbps guaranteed port when that matters.
Can NGINX cache responses?
Yes. The proxy_cache family stores upstream responses on disk under a key you choose, with an in-memory index sized by keys_zone. On a server with NVMe drives, a cache of tens of gigabytes answers repeated requests in microseconds and shields the application during traffic spikes. Set proxy_cache_use_stale updating error timeout so visitors keep receiving the last good page while the backend restarts. For heavily dynamic sites, even a one-second micro-cache flattens bursts dramatically.
What do I need to run it here?
Nothing beyond the operating system. NGINX is packaged in every distribution we install, including Ubuntu Server, Debian and AlmaLinux. Since each machine has one IPv4 address, NGINX is the natural way to host many domains side by side: it chooses the right certificate from the name the browser sends during the TLS handshake. Our High-traffic websites page sizes machines for busy sites.
Machines that suit an NGINX front end
| Model | Processor | Cores | Memory | Drives | Port | Per month |
|---|---|---|---|---|---|---|
| ESSENTIAL-1 | Intel Xeon-E 2386G | 6 | 32 GB | 2x 512 GB SSD NVMe | 1 Gbps unmetered | $38.40 |
| ESSENTIAL-M | AMD Ryzen 9 9900X | 12 | 64 GB | 2x 512 GB SSD NVMe | 1 Gbps unmetered | $70.80 |
| BUSINESS-1 2024 | AMD EPYC 4244P | 6 | 32 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $81.60 |
| BUSINESS-3 2026 | AMD EPYC 4465P | 12 | 64 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $184.20 |
Related pages
What server hosting means
Server hosting explained: shared, virtual, dedicated and colocated, what the provider does in each, what you do, and how to tell which one a project needs.
Read moreInstall a LAMP stack
Install Apache, MariaDB and PHP on Debian, Ubuntu or the Enterprise Linux family, add a virtual host and HTTPS, and tune it for the hardware.
Read moreHigh-traffic websites
Machines with fast cores and guaranteed 3 to 5 Gbps ports for news sites, forums, APIs and busy content platforms.
Read moreLoad balancing
Spreading requests over several servers: layer 4 and layer 7 balancers, algorithms, health checks, sticky sessions and self-built designs with HAProxy.
Read moreQuestions and answers
Is NGINX free?
Yes. The open-source NGINX server is free under a BSD-style licence and packaged by every major Linux distribution. A paid commercial edition with extra modules also exists.
Can NGINX run PHP?
Not by itself. NGINX passes PHP requests to PHP-FPM over FastCGI, through a Unix socket or a loopback port, and serves the static files directly.
How many websites can one NGINX server host?
Hundreds or more. Each site is a server block selected by name, and TLS certificates are chosen per name, so all of them can share one IPv4 address.
Does a reload drop visitor connections?
No. A reload starts new workers with the new configuration and lets the old ones finish their open requests before exiting.
How do I check an NGINX configuration for errors?
Run nginx -t. It parses every included file and reports the file and line of any mistake without touching the running server.