Blueprints · WordPress
Production
30 min · Nginx / PHP-FPM / MariaDB
WordPress high-security and FastCGI cache stack
Denies PHP in uploads, closes xmlrpc.php, rate-limits wp-login.php, sets DISALLOW_FILE_EDIT, and applies 755/644 ownership. MariaDB listens on localhost.
Live config
Baked-in protections
- PHP under wp-content/uploads returns 403
- xmlrpc.php is denied
- wp-login.php is rate-limited
- File editing in wp-admin is disabled
- MariaDB bind-address is 127.0.0.1
Step 1 · nginx
Nginx site
/etc/nginx/sites-available/blog.example.com.conf
FastCGI cache skips logged-in cookies. Login requests share a small zone.
limit_req_zone $binary_remote_addr zone=wplogin:10m rate=5r/m;
fastcgi_cache_path /var/cache/nginx/blog.example.com levels=1:2 keys_zone=blog.example.com:10m inactive=60m;
server {
listen 80;
server_name blog.example.com;
root /var/www/wordpress;
index index.php;
client_max_body_size 32m;
server_tokens off;
location = /xmlrpc.php { deny all; }
location ~* ^/wp-content/uploads/.*\.php$ { deny all; }
location ~ /\.(?!well-known).* { deny all; }
location = /wp-login.php {
limit_req zone=wplogin burst=3 nodelay;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
set $skip_cache 0;
if ($http_cookie ~* "wordpress_logged_in|comment_author") { set $skip_cache 1; }
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_cache blog.example.com;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
}
}
Step 2 · php
wp-config constants
/var/www/wordpress/portgate-hardening.php
Add these lines above the stop-editing marker. They do not by themselves update plugins.
<?php
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true);
define('FORCE_SSL_ADMIN', true);
Step 3 · bash
MariaDB bind and permissions
/root/portgate-blueprints/wordpress-perms.sh
Creates {{DB_NAME}} only if the server package is already installed. Ownership is applied to the WordPress tree.
#!/bin/sh
set -eu
if [ -f /etc/mysql/mariadb.conf.d/50-server.cnf ]; then
sed -i "s/^bind-address.*/bind-address = 127.0.0.1/" /etc/mysql/mariadb.conf.d/50-server.cnf
systemctl reload mariadb || systemctl reload mysql
fi
mkdir -p "/var/www/wordpress"
chown -R "deploy:deploy" "/var/www/wordpress"
find "/var/www/wordpress" -type d -exec chmod 755 {} \;
find "/var/www/wordpress" -type f -exec chmod 644 {} \;
mkdir -p /var/cache/nginx/blog.example.com
chown www-data:www-data /var/cache/nginx/blog.example.com
ln -sfn "/etc/nginx/sites-available/blog.example.com.conf" /etc/nginx/sites-enabled/blog.example.com.conf
nginx -t
systemctl reload nginx
echo "Database name for the installer: wordpress"