Debian 10 LEMP Tuning | For WordPress Sites
Hey tech heads… I'm setting up a few Linodes running Debian 10, nginx, maria and PHP 7.3. I'm going with several 2-4GB Linodes vs a single larger at the moment, just to disperse sites, avoid single point of failure, etc.
I've Googled and Googled and ran mysql tuner, configured PHP-FPM - The basic stuff. All of my WordPress sites are pretty much serving static content, and they're all using the WP-Rocket caching plugin which helps loads.
With that said, do any of you have my.cnf, www.conf, nginx.conf and server block file configs that you'd be willing to share for tuning? I'm not having "problems" per se, but just wanna get the most bang for my buck with each Linode. I'm not a server expert -- Just know enough to get things spinning.
Thanks anyone for advice! I'm gonna paste in key parts of my main configs in case someone spots crazy bad work on my part:
MY.CNF
query_cache_type = 0
query_cache_size=0
tmp_table_size=16M
max_heap_table_size=16M
max_connections=100
table_definition_cache=400
table_open_cache=600
NGINX.CONF
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10s;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 25M;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
SERVER BLOCK SAMPLE:
server {
root /var/www/new.shopsupercars.com/public_html;
access_log /var/www/new.shopsupercars.com/logs/access.log;
error_log /var/www/new.shopsupercars.com/logs/error.log;
index index.php;
server_name new.shopsupercars.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
#try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}
NOTE:
I was gonna add this to the nginx.conf -
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=booyah:100m max_size=1024m inactive=60m;
And then tell the server block to use the "booyah" path, but when I do this, only one so the WP sites will take. If I use curl to pull the site it will show a positive hit on the cache (curl -I https://sitename.com) but other WP sites will not show hits. I know I'm just not configuring PHP-FPM exactly right.
AGAIN - A huge thanks for any assistance!
3 Replies
You have three options:
- You need to install memcached or Redis server that caches WP objects and sql data. Once installed configure WP plugin to use Redis server. Only recommended if you keep DocumentRoot readonly.
- Very easy to use option. Caching wp as static files using https://wordpress.org/plugins/wp-super-cache/ This will speed up too.
- Varnish cache is very powerful when used with a WordPress caching plugin. Check out https://www.varnish-software.com/wiki/content/tutorials/wordpress/index.html and https://codex.wordpress.org/Varnish
- Optional cache static files and wp pages on an edge server provided by CDN such as Cloudflare or Cloudfront.
Thanks NixCraft! All of my sites use WP-Rocket, and that integrates with Varnish or PHP FPM. What I'm wondering is how would Redis affect much if the sites are all converted to static files by a caching plugin? I'm all about your suggestions, and just trying to figure out the best ones. Right now I'm leaning towards Redis and PHP FPM, but maybe Varnish would be easier for purging schedules? Thanks again.