Nginx or Apache on a VPS: which web server to choose

For an ordinary site either one will do, and the deciding factor is what your application expects and what you already know how to run. Apache is the natural choice when the site depends on .htaccess files; nginx is the usual choice for serving static files and for standing in front of an application (a reverse proxy). There is no universal answer, and running both on the same port does not work.

The differences that matter in practice

Point Apache Nginx
Per-folder configuration (.htaccess) Reads .htaccess files in each folder, with no reload. It is what WordPress and many PHP programs assume. Does not read .htaccess. Rules go in the server configuration, and you reload.
PHP Can run PHP inside the server itself (mod_php) or through PHP-FPM. Always hands PHP to a separate process (PHP-FPM).
Serving static files and acting as a proxy Does both, and does them well. Where it is usually picked: little memory per open connection and a short proxy configuration.
Modules Switched on and off with one command (a2enmod). Usually come with the package; adding one may need another package.
Documentation and answers online A lot, from many years. A lot, and more recent for proxying, containers and HTTPS.
Learning curve More directives to learn; .htaccess is forgiving. Leaner, but a syntax error stops the reload.

Choosing by what you will put on it

Your case As a rule
WordPress or another PHP application with .htaccess Apache is the path of least resistance. nginx works, but the .htaccess rules have to be translated by hand.
A Node.js, Python or container app that needs HTTPS nginx (or Apache) in front as a reverse proxy: nginx in front of a container.
Lots of static files, images, downloads nginx.
You will run a control panel on the VPS Whatever the panel installs and expects. Check the panel’s requirements before choosing the system: which operating system to choose.
You just want the site up and already know one of them The one you know. An afternoon lost on the other is not worth it.

What about LiteSpeed? There is a server of that name that reads .htaccess files like Apache and is widely used on shared hosting; on your own VPS, installing and licensing it is your decision and it is not included. To start, stay with one of the two above.

Two web servers cannot use port 80 at the same time. If you install one on top of the other, the second fails to start with “Address already in use”. See who holds the port with sudo ss -tlnp | grep :80, stop and disable the one you do not want (sudo systemctl disable --now apache2), and only then start the other.
Switching later is possible, but it takes work. A quiet weekend is the best time to try. Take a copy first (backing up a VPS: snapshots or files) and test with the hosts file before you change the DNS.

Not sure which fits what you are about to install? Tell us what you plan to run and we will tell you what is on our side: the server and the network.

Open a support ticket

SEE ALSO

Installing nginx on Ubuntu

Installing Apache and setting up a virtual host

nginx as a reverse proxy in front of a container

VPS, Cloud or Dedicated: how to choose

RECOMMENDED PRODUCT

VPS server with root access

Resources of your own, the OS you choose, reinstall whenever you like. from $8.39/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?