Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Run WordPress over HTTPS on CentOS with Nginx

A practical guide to serving WordPress securely on CentOS with Nginx: configure PHP-FPM, install and renew TLS, redirect HTTP, set WordPress URLs, keep SELinux enforcing, and verify uploads, redirects, and firewall rules.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run WordPress over HTTPS on CentOS by putting Nginx in front of PHP-FPM, serving the site from a TLS-enabled server block on port 443, redirecting port 80 to HTTPS, and configuring WordPress to use the secure URL. Keep SELinux enforcing, allow ports 80 and 443 in firewalld, protect the certificate key, and test every change before reloading Nginx.

What the finished setup looks like

A production installation has four cooperating layers:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Nginx: accepts HTTP and HTTPS connections, serves static files, applies redirects and access rules, and sends PHP requests to PHP-FPM.
  • PHP-FPM: executes WordPress PHP through a Unix socket or loopback TCP listener.
  • WordPress: stores its canonical HTTPS URLs and uses the secure scheme for administration and generated links.
  • CentOS controls: firewalld permits the web ports and SELinux labels allow the web processes to read or write only where policy permits.

WordPress supports Nginx as a standalone web server. Unlike Apache, Nginx has no .htaccess layer, so rewrite rules, HTTPS redirects, hidden-file restrictions, and upload protections must be written in administrator-managed server configuration.

Prerequisites and decisions

Use a maintained platform

Start with a supported CentOS Stream release or a compatible Red Hat-family distribution. Install Nginx, PHP-FPM, the PHP extensions required by your WordPress version and plugins, and a supported database using the distribution’s package tooling. WordPress warns that obsolete PHP and database releases can expose a site to security vulnerabilities, so support status is part of the deployment rather than a later optimization.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Choose the canonical hostname

Decide whether the public address is, for example, example.com or www.example.com. Obtain a certificate covering every hostname you will actually serve, then use one canonical name in WordPress Address, Site Address, redirects, and any reverse-proxy configuration. A certificate for only one name will not make the other name secure.

Choose the PHP-FPM transport

PHP-FPM can listen on a Unix socket or on a loopback TCP address. Either is valid; the important requirement is that the value in Nginx’s fastcgi_pass exactly matches the PHP-FPM pool listener and that the Nginx/PHP-FPM processes can access it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare the document root and permissions

Create a dedicated site root such as /var/www/example.com. Make its owner, group, and SELinux contexts consistent with the account and policy used by Nginx and PHP-FPM. Do not recursively make the entire tree world-writable. WordPress needs write access to selected content locations, not unrestricted write access to the operating-system files.

On a CentOS-family host, a denial caused by SELinux can look like an ordinary Unix permission failure. Check both mode bits and security contexts before changing ownership or permissions. Use ls -Z to inspect labels and review audit records when a process is denied.

Configure PHP-FPM for WordPress

Set the pool listener

In the PHP-FPM pool configuration, select a Unix socket or loopback address and ensure the service is enabled and running. Record the exact listener; it will be copied into the Nginx server block.

; Example only: use the listener defined by your installed pool
listen = /run/php-fpm/www.sock

The path above is an example pattern, not a universal CentOS filename. Confirm the actual socket created by your installed PHP-FPM package before using it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pass the FastCGI parameters

Nginx must pass the script filename and the standard request parameters to PHP-FPM. A typical WordPress location includes the document root, the requested script, and the query string:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
location ~ .php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php-fpm/www.sock;
}

Set an upload limit appropriate for the media your site accepts. The Nginx limit and PHP limits must agree; otherwise a file can be rejected by one layer even when the other allows it. Change only the limits you need and verify the resulting behavior with a normal media upload.

Create the Nginx HTTP and HTTPS server blocks

Port 80: redirect, do not duplicate the site

Use a separate HTTP server block for the canonical domain. Its only job is to return a permanent redirect to the same host and URI under HTTPS. Keeping the HTTP block simple avoids accidentally serving a second, insecure copy of WordPress.

server {
    listen 80;
    server_name example.com;

    return 301 https://example.com$request_uri;
}

If you also answer for a www name, either include it in the certificate and redirect it deliberately to the canonical name, or create a separate redirect block. Do not create a redirect loop by sending HTTPS back to HTTP.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Port 443: serve WordPress over TLS

The secure server block must listen with SSL enabled, identify the hostname, point to the WordPress root, and reference both the certificate chain and private key:

server {
    listen 443 ssl;
    server_name example.com;

    root /var/www/example.com;
    index index.php;

    ssl_certificate     /etc/pki/tls/certs/example.com.fullchain.pem;
    ssl_certificate_key /etc/pki/tls/private/example.com.key;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location = /index.php {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php-fpm/www.sock;
    }

    location ~ .php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php-fpm/www.sock;
    }

    location ~ /. {
        deny all;
    }

    location ~* /(?:uploads|files)/.*.php$ {
        deny all;
    }
}

The try_files fallback is WordPress’s front-controller pattern: existing files and directories are served directly, while other requests are sent to index.php with their query arguments. The dot-file rule blocks files such as .htaccess and .env. The uploads rule prevents a PHP file placed in a media directory from being executed.

Protect the private key

A certificate can be publicly served; its private key cannot. Store the key in an access-controlled location. Nginx’s master process must be able to read it at startup, but unrelated users should not. Never place the key in the web root or make it broadly readable just to work around a startup error.

Validate before every reload

nginx -t

Reload only after the test reports a valid configuration. A malformed directive, unreadable key, missing certificate chain, or mismatched bracket can otherwise take the site offline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Install and renew the TLS certificate

Install the complete chain

Obtain a certificate for the production hostname from your chosen certificate authority. Install the full chain and private key at the paths referenced by the HTTPS server block. An incorrectly ordered chain can prevent Nginx from starting or leave clients without an intermediate certificate.

Confirm that the certificate names match the hostname users enter and that the server clock is correct. Test from a client that validates the complete chain, not merely that port 443 accepts a connection.

Automate renewal and reload safely

Use the certificate authority’s supported renewal method. Renewal is incomplete until the new files are installed and Nginx has reloaded successfully. The renewal procedure should run nginx -t before reloading and should alert you if validation or reload fails. Do not wait for expiry to discover that the Nginx worker cannot read the replacement key.

Point WordPress at HTTPS

Set both WordPress URLs

After the HTTPS virtual host responds correctly, set WordPress Address and Site Address to the secure form, such as https://example.com. Both settings matter: one identifies where the WordPress files are addressed and the other is the public site URL. Changing only one can leave redirects, login links, or generated assets on the wrong scheme.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Force secure administration

To require TLS for logins and the administration area, add this directive to wp-config.php:

define( 'FORCE_SSL_ADMIN', true );

Place it before the file’s completion comment and keep the file outside public download paths. Test /wp-login.php and the dashboard after enabling it.

Account for a TLS-terminating proxy

If another proxy or load balancer terminates TLS before the request reaches Nginx, the origin may see an HTTP connection even though the browser used HTTPS. Pass the proxy’s X-Forwarded-Proto value and configure WordPress’s HTTPS detection accordingly. Without that coordination, WordPress can issue a redirect loop or generate HTTP links for an HTTPS page. Only trust this header from your controlled proxy; accepting arbitrary client-supplied values would weaken the design.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Open firewalld ports permanently

Permit both HTTP and HTTPS. Port 80 remains necessary when it performs the redirect and when certificate validation uses an HTTP challenge.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-services

The --permanent changes survive a restart; the reload applies them to the running firewall. Runtime-only rules disappear after reboot. If your policy uses explicit ports instead of service names, allow TCP 80 and 443 and then perform the same reload and verification.

Keep SELinux enforcing

SELinux is typically installed on Red Hat-family distributions, including CentOS. It can block Nginx or PHP-FPM independently of Unix mode bits. Do not disable it as a first response.

  • Inspect labels with ls -Z on the document root, WordPress content directories, sockets, and certificate files.
  • Review AVC denial records when a request fails despite apparently correct ownership and permissions.
  • Apply the appropriate web-content labels and SELinux booleans for the access WordPress actually needs.
  • Give write access only to required directories, commonly selected content paths, rather than the complete application tree.

After correcting a label or boolean, repeat the failing request and confirm that the denial has disappeared from the logs. A working page alone does not prove the policy is correct if the fix was an unsafe permission change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Harden WordPress-specific request paths

Block hidden files

Keep the dot-file denial in the HTTPS server block. It prevents accidental disclosure of configuration, repository metadata, and Apache-era files such as .htaccess. Nginx will not enforce these rules automatically because it does not read .htaccess.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable PHP execution in uploads

Media directories should contain data, not executable application code. Deny PHP below wp-content/uploads (and any legacy files directory used by the installation). The location rule must take precedence over a broad PHP location, so test the effective configuration rather than assuming order is correct.

Do not expose configuration backups

Keep database dumps, editor swap files, deployment archives, and copied configuration files outside the document root. A deny rule is useful defense in depth, but it is not a substitute for storing secrets away from a public path.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Verification checklist

  1. Run nginx -t; correct every error before reloading.
  2. Request the HTTP URL and confirm one permanent redirect to the expected HTTPS host and identical path.
  3. Open the HTTPS site in a client that validates the certificate hostname and complete chain.
  4. Visit /wp-login.php and the dashboard over HTTPS, then confirm that login cookies and administration remain secure.
  5. Inspect page source and browser network requests for HTTP images, scripts, stylesheets, or API calls that would create mixed content.
  6. Upload an ordinary media file and confirm it loads normally.
  7. Create a harmless PHP file inside the uploads directory, request it, and verify that execution is denied rather than returning PHP output. Remove the test file immediately.
  8. Check both firewalld runtime and permanent configuration and confirm that TCP 80 and 443 are reachable from the intended network.
  9. Review Nginx, PHP-FPM, and SELinux logs for denied requests, upstream failures, permission errors, and certificate problems.

Troubleshoot by symptom

502 Bad Gateway

Nginx cannot reach PHP-FPM. Check that PHP-FPM is running, that its socket or loopback address matches fastcgi_pass, and that SELinux permits the connection. A stale socket path after a package update is a common cause.

403 or 404 responses for valid WordPress URLs

Check the document root, file ownership, labels, and the try_files fallback. A PHP location with try_files $uri =404 should reject nonexistent scripts while the root location sends permalink requests to /index.php.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redirect loop

Check that WordPress Address and Site Address both use HTTPS, that the port-80 block redirects only toward HTTPS, and that a TLS-terminating proxy forwards X-Forwarded-Proto correctly. Do not make WordPress trust an uncontrolled header from the public internet.

Certificate warning or Nginx startup failure

Verify the certificate hostname, file paths, permissions, private-key match, and chain order. Run nginx -t and inspect the exact error before changing file modes.

Uploads fail after enabling SELinux

Review the AVC denial and the label on the intended writable directory. Correct the context or narrowly required boolean; do not make the whole WordPress tree writable or disable SELinux.

Self-managed CentOS/Nginx or managed WordPress hosting?

Decision area Self-managed CentOS with Nginx Managed WordPress hosting
Administrative effort You configure Nginx, PHP-FPM, WordPress, firewalld, SELinux, certificates, and renewals. The provider normally supplies the web stack and exposes a narrower control surface.
Control Direct control over server blocks, PHP-FPM pools, labels, caching, and performance tuning. Changes are limited to the provider’s supported settings.
TLS automation You install the chain, protect the key, renew, test, and reload. Certificate issuance and renewal may be integrated, but you must verify what is covered.
Patching You track and patch CentOS, Nginx, PHP, the database, WordPress, themes, and plugins. The provider may patch infrastructure; WordPress and extension responsibilities vary.
Backups and monitoring You design backup retention, restore tests, log collection, and alerts. Plans differ; confirm backup scope, retention, restore process, and monitoring.
Support You diagnose upstream, firewall, certificate, and SELinux failures yourself. Support may cover platform incidents but not every plugin or custom configuration.

Choose self-management when you need operating-system and Nginx control and can maintain the full security boundary. Choose managed service when reducing routine server administration is more valuable than customizing the underlying stack; verify certificate renewal, backups, patch scope, and support boundaries before migrating.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ongoing maintenance

  • Keep CentOS, Nginx, PHP, PHP-FPM, the database, WordPress core, themes, and plugins on maintained releases.
  • Monitor certificate expiry and test renewal before the final days of validity.
  • Back up the database and uploads, and perform restores rather than merely checking that backup jobs completed.
  • Re-run configuration and HTTPS checks after changes to server blocks, PHP-FPM pools, proxies, or firewall policy.
  • Review logs and SELinux denials routinely so a security control does not silently become an availability problem.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.