<?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>caddy &#8211; xyze.co.uk</title>
	<atom:link href="https://www.xyze.co.uk/tag/caddy/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.3</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>
	</channel>
</rss>
