Month: July 2024

WordPress Caching with W3 Total Cache and memcached

There is much on this topic, this is just one solution.

W3 Total Cache is a well known performance plugin for WordPress, and it can use memcached.

memcached should already be listening on loopback, not on a public ip!, on a tcp socket:

root@www:~# netstat -lnp --tcp |head -3
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      681/memcached

Going to need the php extension to connect to the memcached server:

apt install php8.2-memcached

After which, the main things in W3TC we are looking for are object cache (php), page cache, and database cache and all three are working so we are all set.

Apache MPM Event with PHP-FPM on Debian 12

Apache by default comes with an old crusty style of doing things which includes MPM prefork and mod_php. I am going to instead use the threaded event multi-processing module.


apachectl -M | grep 'mpm'

root@www:~#  apachectl -M | grep 'mpm'
mpm_prefork_module (shared)


root@www:~# a2query -m |grep php
php8.2 (enabled by maintainer script)

a2dismod php8.2
a2dismod mpm_prefork
a2enmod mpm_event

apt install php-fpm

Creating config file /etc/php/8.2/fpm/php.ini with new version
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php8.2-fpm.service → /lib/systemd/system/php8.2-fpm.service.
Setting up php-fpm (2:8.2+93) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for php8.2-fpm (8.2.20-1~deb12u1) ...
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.


apt install libapache2-mod-fcgid
Uses unix socket.
		
a2enconf php8.2-fpm		
a2enmod proxy
a2enmod proxy_fcgi

apachectl configtest
Syntax OK

systemctl restart apache2

apachectl -M | grep 'mpm'
mpm_event_module (shared)
 
[Top]

Automatically update wp cli

wp cli is a command line tool to do lots of wordpress operations..

Here is a cron job to automaticall update wp cli every hour on the hour:

0 */1 * * * wp cli update --yes

[Top]