Nginx Config Generator for WordPress and Apps

Create a ready Nginx server block: WordPress with PHP-FPM, a proxy for Node or Python apps, or a static site, with HTTPS, www redirects, compression, caching and security headers.

Create the config
example.com.confserver { listen 443 ssl http2; server_name example.com; location ~ \.php$ { fastcgi_pass php-fpm; }}nginx -t ✓

Generator

Essential Nginx commands

Test confignginx -t
Apply changessystemctl reload nginx
Error logtail -f /var/log/nginx/error.log
Issue a certificatecertbot --nginx -d example.com

Before you enable it

Do

  • Run nginx -t before every reload
  • Point the domain A record to the server before issuing the certificate
  • Check the PHP-FPM socket name in /run/php/

Avoid

  • Editing the main nginx.conf for each site; give each site its own file
  • Exposing the app port to the world; the proxy is enough

Example: WordPress on a new VPS

After preparing the server with the VPS setup script, install Nginx, PHP-FPM and a database, then create the config here with the WordPress type. Put the file in /etc/nginx/sites-available, enable it, run nginx -t then reload, and issue the certificate with the certbot command shown below the config.

Key terms

Short definitions of what you meet along the way.

Server block
A section of Nginx config defining one site and its domain.
PHP-FPM
The service that runs PHP files; Nginx passes requests to it.
Reverse proxy
Nginx receives visitors and forwards requests to an app on an internal port.

Frequently asked questions

Did not find your answer? Ask us on WhatsApp

Does htaccess work with Nginx?

No, Nginx ignores htaccess. Rules go in the site file as this generator does.

Do I need Nginx on shared hosting?

No, shared hosting is managed for you. This is for VPS servers.

What if nginx -t fails?

It names the line and the error. Fix it before reloading; the current site keeps running on the old config.

Need a server with Nginx ready?

VPS servers, and we set up Nginx and PHP on request.

Contact us on WhatsApp