<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wordpress &#8211; xyze.co.uk</title>
	<atom:link href="https://www.xyze.co.uk/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.xyze.co.uk</link>
	<description>Sysadmin stuff</description>
	<lastBuildDate>Fri, 12 Dec 2025 12:31:50 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Caddy</title>
		<link>https://www.xyze.co.uk/caddy/</link>
					<comments>https://www.xyze.co.uk/caddy/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 24 May 2025 13:11:23 +0000</pubDate>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[Contents]]></category>
		<category><![CDATA[caddy]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://www.xyze.co.uk/?p=93</guid>

					<description><![CDATA[I&#8217;d wanted to try Caddy web server for a while and upgrading to the latest version of WordPress on my website broke the site. Something to do with their WP Super Cache but I couldn&#8217;t find anything via Google nor was opening a support ticket useful so I decided to replace it with a new ... <a title="Caddy" class="read-more" href="https://www.xyze.co.uk/caddy/" aria-label="Read more about Caddy">Read more</a>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;d wanted to try Caddy web server for a while and upgrading to the latest version of WordPress on my website broke the site. Something to do with their WP Super Cache but I couldn&#8217;t find anything via Google nor was opening a support ticket useful so I decided to replace it with a new server.</p>
<p>As its a low traffic site I can do it on one of Google&#8217;s smallest servers, again using an e2-micro configured with Ubuntu 24.04 Minimal.</p>
<p>Caddy installation is detailed here: https://caddyserver.com/docs/install#debian-ubuntu-raspbian</p>
<pre>sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
</pre>
<p>I then installed the stuff that I need that&#8217;s missing from Ubuntu Minimal:</p>
<pre>sudo apt install bash-completion nano htop cron</pre>
<p>I always change the history size in the shell so it keeps more, changing HISTSIZE=100000<br />
HISTFILESIZE=20000:</p>
<pre>nano .bashrc</pre>
<p>With only 1GB ram, I always install zswap:</p>
<pre>sudo nano /etc/default/grub.d/50-cloudimg-settings.cfg
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,115200 zswap.enabled=1 zswap.shrinker_enabled=1 zswap.compressor=zstd zswap.zpool=zsmalloc"
sudo update-grub

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo nano /etc/fstab
/swapfile swap swap defaults 0 0

sudo crontab -e
@reboot echo zstd &gt; /sys/module/zswap/parameters/compressor
</pre>
<p>If using btrfs then this has to be used as it needs to be created without copy-on-write:<br />
sudo btrfs filesystem mkswapfile &#8211;size 1G /swapfile</p>
<p>Use swapon or reboot to activate. For some reason the zswap compressor isn&#8217;t enabled at boot time, so the kludge in a crontab activates it.<br />
It can be checked with:</p>
<pre>grep -R . /sys/module/zswap/parameters</pre>
<p>I normally configure swappiness which prevents kswapd kicking in and slowing everything down:</p>
<pre>sudo nano /etc/sysctl.conf
vm.swappiness = 1</pre>
<p>I got the latest WordPress and installed it in the usual place:</p>
<pre>wget https://wordpress.org/latest.tar.gz
tar zxvf latest.tar.gz
sudo mkdir -p /var/www/html
sudo mv wordpress/ /var/www/html/
sudo chown -R www-data: /var/www/html/wordpress/
</pre>
<p>I then installed mysql and php:</p>
<pre>sudo apt install mariadb-server php-apcu php-fpm php-mysql php-curl php-xml php-imagick php-mbstring php-zip php-gd php-intl
</pre>
<p>I then configured mysql:</p>
<pre>sudo mysql_secure_installation
sudo mysql

CREATE USER "USER"@"localhost" IDENTIFIED BY "PASSWORD";
CREATE DATABASE xyze;
GRANT ALL PRIVILEGES ON xyze.* TO "USER"@"localhost";
FLUSH PRIVILEGES;
</pre>
<p>This says that character set and collation are defaults so no need to specify explicitly: https://dev.mysql.com/doc/refman/8.0/en/charset-server.html</p>
<p>Caddy comes with a sample config: /etc/caddy/Caddyfile which will display a sample webpage when tested in the browser. Searching Google for a config brought up: https://caddy.community/t/setting-up-wordpress-with-caddy-on-ubuntu/18448 which I&#8217;ve altered slightly:</p>
<pre>xyze.co.uk {
	redir https://www.xyze.co.uk
}

www.xyze.co.uk {
    # good practice to signal on behalf of who 
    # are the certs getting issue
	tls james@xyze.co.uk

    # logs are optional
	log {
		output file /var/log/caddy/xyze.co.uk
		format console
	}

	root * /var/www/html/wordpress
	encode zstd gzip
	file_server
	php_fastcgi unix//run/php/php-fpm.sock

	@disallowed {
		path /xmlrpc.php
		path *.sql
		path /wp-content/uploads/*.php
	}

	rewrite @disallowed '/index.php'
}
</pre>
<p>Letsencrypt is configured by Caddy automatically so no Certbot configuration is necessary. I then set up WordPress via the browser using the mysql config from earlier.</p>
<p>I then dumped the previous db and loaded it into the new one:</p>
<pre>mysqldump -uUSER -pPASSWORD xyze &gt; /var/www/html/wordpress/sql/wp-backup.sql
mysql -uUSER -pPASSWORD xyze &lt; /var/www/html/wordpress/sql/wp-backup.sql
</pre>
<p>Logging into WordPress needed a db update and from there I configured the caching.<br />
I&#8217;ve found that apcu is faster than Redis so have installed this one which needs the php-apcu I installed earlier:<br />
https://wordpress.org/plugins/atec-cache-apcu/ This plugin gives opcache recommended settings: https://wordpress.org/plugins/atec-cache-info/ which are configured in:</p>
<pre>sudo nano /etc/php/8.3/fpm/php.ini
sudo systemctl restart php8.3-fpm caddy</pre>
<p>Unfortunately their page cache seems buggy and they&#8217;ve superseded it in one of their other plugins, so I&#8217;m using https://wordpress.org/plugins/powered-cache/ which I&#8217;ve used successfully before. The other plugin needed is the Cloudflare one which will update Cloudflare when a new post is made: https://wordpress.org/plugins/cloudflare/</p>
<p>I like to backup the db every night to make it ready for the external rsync backup:</p>
<pre>sudo crontab -l

# m h  dom mon dow   command
@reboot echo zstd &gt; /sys/module/zswap/parameters/compressor
35 0 * * * /usr/bin/mysqldump -uUSER -pPASSWORD xyze &gt; /var/www/html/wordpress/sql/wp-backup.sql
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xyze.co.uk/caddy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress, Lighttpd, and Cloudflare</title>
		<link>https://www.xyze.co.uk/wordpress-lighttpd-and-cloudflare/</link>
					<comments>https://www.xyze.co.uk/wordpress-lighttpd-and-cloudflare/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 03 Oct 2022 14:16:05 +0000</pubDate>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[Contents]]></category>
		<category><![CDATA[22.04]]></category>
		<category><![CDATA[certbot]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[letsencrypt]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://xyze.co.uk/?p=71</guid>

					<description><![CDATA[I’ve been meaning to try Lighttpd for ages as I wanted to downgrade my server to save money and it takes the least amount of memory compared with apache or nginx. Installed with the help of: https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/ https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/ But had to make changes too. james@instance-1:~$ sudo mysql CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ... <a title="WordPress, Lighttpd, and Cloudflare" class="read-more" href="https://www.xyze.co.uk/wordpress-lighttpd-and-cloudflare/" aria-label="Read more about WordPress, Lighttpd, and Cloudflare">Read more</a>]]></description>
										<content:encoded><![CDATA[<div class="entry-content">
<p>I’ve been meaning to try Lighttpd for ages as I wanted to downgrade my server to save money and it takes the least amount of memory compared with apache or nginx.</p>
<p>Installed with the help of:<br />
<a href="https://web.archive.org/web/20240919030526/https://web.archive.org/web/20201102175615/https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/" rel="noopener">https://www.how2shout.com/linux/install-wordpress-on-lighttpd-web-server-ubuntu/</a><br />
<a href="https://web.archive.org/web/20240919030526/https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/" rel="noopener">https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/</a><br />
But had to make changes too.</p>
<pre>james@instance-1:~$ sudo mysql
CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
create user 'demoh2s'@'localhost' identified by 'password';
GRANT ALL PRIVILEGES ON `mydatabase`.* to `demoh2s`@localhost;
exit
</pre>
<pre>james@instance-1:~$ sudo apt install php php-cgi php-cli php-fpm php-curl php-gd php-mysql php-mbstring zip unzip php-zip php-xml php-intl php-imagick apache2-</pre>
<p>I’m installing on Ubuntu 22.04 Minimal <a href="https://web.archive.org/web/20240919030526/https://wiki.ubuntu.com/Minimal" rel="noopener">https://wiki.ubuntu.com/Minimal</a> on Google’s cloud platform. I try to keep original config files intact so have only altered the server.document-root and rewrite rules in lighttpd.conf</p>
<p>There is a tool similar to the one in apache to install the symlinks in /etc/lighttpd/conf-enabled</p>
<pre>james@instance-1:~$ sudo lighty-enable-mod fastcgi fastcgi-php auth deflate rewrite accesslog</pre>
<h4>Rewriting</h4>
<p>At first all the permalinks were showing ‘index.php’ which apache wasn’t doing before so I gathered together some rewriting rules from various places via Google. Through trial and error I ascertained that the order is significant, and I’ve included the rules I found but commented out. These still aren’t definitive but seem to be a work in progress and WordPress only seems to need the 4 uncommented ones at present. You can Google them to see where they came from:</p>
<pre>lighttpd "^/(wp-admin.+).*/?" =&gt; "$0"</pre>
<p>The Lighttpd wiki is very useful too: <a href="https://web.archive.org/web/20240919030526/https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs" rel="noopener">https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs</a></p>
<pre>james@instance-1:/etc/lighttpd$ cat lighttpd.conf
server.modules = (
	"mod_indexfile",
	"mod_access",
	"mod_alias",
 	"mod_redirect",
)

#url.rewrite = (
#"^/?$" =&gt; "/index.php",
# Exclude common directories
#"^/(wp-.+)$" =&gt; "$0",
# Exclude letsencrypt certbot
#"^/(.well-.+)$" =&gt; "$0",
#"^/xmlrpc.php" =&gt; "$0",
#"^/sitemap.xml" =&gt; "$0",
# Handle permalinks and feeds
#"^/(.+)/?$" =&gt; "/index.php/$1"
#)

url.rewrite-if-not-file = (
 "^/(wp-admin.+).*/?" =&gt; "$0",
# Exclude letsencrypt certbot
 "^/(.well-.+)$" =&gt; "$0",
# REST API for block editor &amp; Jetpack 
 "(?:\?(.*))?$" =&gt; "/index.php?$1",
# "(\/styles\/|\/images\/|\/scripts\/)" =&gt; "$0",
 "^/(wp-.+).*/?" =&gt; "$0",
# "^/images/.*/?" =&gt; "$0",
# "^/temp/.*/?" =&gt; "$0",
# "^/keyword/([A-Za-z_0-9\-]+)/?$" =&gt; "/index.php?keyword=$1",
# "^/.*?(\?.*)?$" =&gt; "/index.php$1"
)

server.document-root        = "/var/www/html/xyze.co.uk"
.
.
.

</pre>
<p>You need to set the permalinks in wp-admin as well under Settings, Permalinks:</p>
<pre>Custom Structure https://www.xyze.co.uk/index.php /%postname%/</pre>
<h4>WordPress (this is not needed if using Let’s Encrypt)</h4>
<p>The way I’ve installed WordPress before is to just use http and then use the ‘Flexible’ shared Cloudflare certificate that encrypts traffic from the user to Cloudflare but then its served to Cloudflare using http. This has worked fine with apache but both the classic editor and block editor weren’t working in Lighttpd and searching with the error from the block editor I stumbled across this:<br />
<a href="https://web.archive.org/web/20240919030526/https://wordpress.org/support/topic/publishing-failed-you-are-probably-offline/" rel="noopener">https://wordpress.org/support/topic/publishing-failed-you-are-probably-offline/</a></p>
<pre>james@instance-1:~$ cat /var/www/html/xyze.co.uk/wp-config.php

/* Add any custom values between this line and the "stop editing" line. */

define( 'WP_SITEURL', 'http://xyze.co.uk' );
define( 'WP_HOME', 'http://xyze.co.uk' );

/* That's all, stop editing! Happy publishing. */
</pre>
<p>This allowed me to use http if I wanted to add or edit a post and Cloudflare’s Flexible https worked too.</p>
<h4>Let’s Encrypt</h4>
<p>However now we have Let’s Encrypt with certbot, its better to have proper https.</p>
<pre>james@instance-1:~$ sudo apt install certbot
james@instance-1:~$ sudo certbot certonly --webroot -w /var/www/html/xyze.co.uk/ -d www.xyze.co.uk
</pre>
<p><a href="https://web.archive.org/web/20240919030526/https://eff-certbot.readthedocs.io/en/stable/using.html" rel="noopener">https://eff-certbot.readthedocs.io/en/stable/using.html</a><br />
Says that “For historical reasons, the containing directories are created with permissions of 0700 meaning that certificates are accessible only to servers that run as the root user. If you will never downgrade to an older version of Certbot, then you can safely fix this using chmod 0755 /etc/letsencrypt/{live,archive}”<br />
Which I did.</p>
<p>This time I copied /etc/lighttpd/conf-available/10-ssl.conf to 10-ssl-xyze.conf and then created the symlink manually.</p>
<pre>james@instance-1:/etc/lighttpd/conf-enabled$ sudo ln -s ../conf-available/10-ssl-xyze.conf
james@instance-1:/etc/lighttpd/conf-enabled$ cat 10-ssl-xyze.conf
# /usr/share/doc/lighttpd/ssl.txt
# -*- conflicts: mbedtls, gnutls, nss, wolfssl -*-

server.modules += ( "mod_openssl" )

# ssl.* in global scope gets inherited by
#   $SERVER["socket"] == "..." { ssl.engine = "enable" }
#ssl.pemfile = "/etc/lighttpd/server.pem"
ssl.pemfile = "/etc/letsencrypt/live/www.xyze.co.uk/fullchain.pem" # Combined Certificate
ssl.privkey = "/etc/letsencrypt/live/www.xyze.co.uk/privkey.pem"

ssl.cipher-list = "HIGH"

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
}

$HTTP["scheme"] == "http" {
$HTTP["host"] == "www.xyze.co.uk" { # HTTP URL
url.redirect = ("/.*" =&gt; "https://www.xyze.co.uk$0") # Redirection HTTPS URL
}
}

include_shell "/usr/share/lighttpd/use-ipv6.pl 443"
</pre>
<p>At first I copied the example from the howtoforge link above but lighttpd kept failing to restart producing an error like this: ssl.pemfile has to be set in same $SERVER[“socket”] scope as other ssl.* directives</p>
<p>Eventually I worked out that the pem files had to be in the global file or in all of the socket, scheme, and host directives, so I moved it out of the socket directive so they’re now global and inherited by all of them.</p>
<p>Finally I changed the wp-config.php to https – or you could comment them out as long as they’re set to https in Settings, General on the WordPress Dashboard. And Cloudflare can now use ‘Full’ encryption and ‘<span class="c_c">Always Use HTTPS’.</span></p>
<h4>Cloudflare</h4>
<p>I added some Firewall rules using the dash console:</p>
<pre>WordPress Spam Filter
(http.request.uri.path contains "wp-comments-post.php") or (http.request.uri.path contains "wp-login.php")
Managed Challenge

Protect the wp-admin Area
(http.request.uri.path contains "/wp-admin/" and not http.request.uri.path contains "/wp-admin/admin-ajax.php" and not http.request.uri.path contains "/wp-admin/theme-editor.php")
Managed Challenge

Block xmlrpc.php Attacks
(http.request.uri.path contains "/xmlrpc.php")
Block

Block wp-login
(http.request.uri.path contains "wp-login.php" and ip.geoip.country ne "GB")
Block
</pre>
<h4>Postscript</h4>
<p>I followed a guide to install Redis <a href="https://web.archive.org/web/20240919030526/https://www.section.io/engineering-education/how-to-set-up-and-configure-redis-caching-for-wordpress/" rel="noopener">here</a> except I installed the php client as it seemed to work faster. This uses a WordPress plugin from <a href="https://web.archive.org/web/20240919030526/https://en-gb.wordpress.org/plugins/redis-cache/" rel="noopener">here.</a> Php will need reloading but I rebooted as I’d also installed some kernel updates.</p>
<pre>james@instance-1:~$ sudo apt install php-redis</pre>
<p>I also installed a Cloudflare cache plugin from <a href="https://web.archive.org/web/20240919030526/https://wordpress.org/plugins/wp-cloudflare-page-cache/" rel="noopener">here</a> which needs your api key from Cloudflare and works really well. There is also the W3 Total Cache in place of the redis cache plugin.</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xyze.co.uk/wordpress-lighttpd-and-cloudflare/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
