Installing Castopod 1.6.5 w/ MySQL and behind Caddy

I recently set up the self-hosted podcasting solution Castopod. Here's a quick rundown. It's closely based on official instructions though.

Dependencies

I already had the necessary dependencies installed, but it should be these commands:

# Caddy (see https://caddyserver.com/docs/install#debian-ubuntu-raspbian)
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
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
# MySQL (see https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04)
sudo apt install mysql-server mysql-client php-mysql
systemctl start mysql.service
service mysql-server start
mysql_secure_installation
service mysql-server restart
mysql -u root -p
# PHP
sudo apt install php-fpm php-curl php-mbstring php-xml php-mysql

Also, add a DNS entry pointing your (sub-)domain to your server IP.

Preparing the MySQL DB

Next, we create a DB user called castopod and a database of the same name. We then grant the user full access to the database:

# Login
mysql -p
# Replace 'PASSWORD on the next line'
create user 'castopod'@'%' identified by 'PASSWORD';
create database castopod;
grant all privileges on castopod.* to 'castopod'@'%';
exit

Installing Castopod

We install Castopod to the caddy user home directory:

cd /home/caddy
wget https://code.castopod.org/adaures/castopod/uploads/fe7be588c53a9e1ed63af47e6e624ad1/castopod-1.6.5.zip
unzip castopod-1.6.5.zip
# All files are now unzipped in the folder ./castopod/
chmod 774 -R castopod
chown caddy:www-data -R castopod
# We link the folder out to where caddy will look
mkdir -p /usr/share/caddy/YOUR.DOMAIN
chown caddy:caddy -R /usr/share/caddy
ln -s /home/caddy/castopod/public /usr/share/caddy/YOUR.DOMAIN/html

Now we enable a cronjob that handles stuff like fediverse integration.

Run crontab -e and add the following line to the bottom of it:

* * * * * /path/to/php /path/to/castopod/spark tasks:run >> /dev/null 2>&1

We probably also want to be able to upload files bigger than the default 2MB, so we open up the php configuration with our favourite text editor. It's located at /etc/php/8.1/fpm/php.ini.

Search for these three values and update them, e.g. to these:

post_max_size = 200M
memory_limit = 256M
post_max_size = 200M

Pointing Caddy

Update the Caddyfile (/etc/caddy/Caddyfile):

YOUR.DOMAIN {
	encode zstd gzip
	root * /usr/share/caddy/YOUR.DOMAIN/html
	php_fastcgi unix//run/php/php8.1-fpm.sock
	file_server
}

(Re-)starting Everything

Now we need to reload all our services to use the new configurations.

systemctl restart php8.1-fpm.service
systemctl restart caddy
# or
caddy reload --config /etc/caddy/Caddyfile

All you need to do now is visit YOUR.DOMAIN/cp-wizard to finish the setup wizard.

If you have any questions please refer to official documentation or Castopod support. I will not help you debug your installation.

___ Reach out via Mastodon @Optional@dice.camp or shoot me an email