Self hosting your podcasts?
Installation guide for Castopod
Today’s article is a bit special since it was written by @and0uille! She will explain in detail how to install your own castopod instance to host podcasts. If you want to see the end result before jumping in, you can visit the podcast SpaceSheep.
Contents
- Introduction
- Before we begin
- MariaDB server configuration
- Configure Apache
- Finish the install using a web browser
- Troubleshooting
- Miscellaneous : Deleting a podcast
- Conclusion
Introduction
The Castopod project, while still in alpha version already allows its users to self-host their podcasts in the fediverse (and it’s awesome).
It is the perfect solution to host the first podcasts created by @Moutmout@framapiaf.org who I helped out with the server hosting.
There are already installation instructions on Castopod’s project Gitlab, but I wanted to make them a bit more accessible to podcasters with less experience in web hosting. So here is a detailled installation procedure which (I hope) will help some of you (until maybe castopod is adopted by kittens)
I installed castopod on a Debian 11 server with:
- Apache 2.4.48
- MariaDB
- PHP 8.1
- Castopod v1.0.0-alpha.70 (31/08/2021)
Before we begin
Install these required packages :
$ sudo apt update && sudo apt upgrade -y
$ sudo apt install apache2 mariadb-server certbot apt-transport-https \
lsb-release ca-certificates curl wget unzip
Install php8.1, which is as of today only availbale in the Debian sid/unstable
repository. We’ll install PHP 8.1 from Ondřej Surý repository:
$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/php.list
$ sudo apt update && sudo apt upgrade
$ sudo apt install php8.1 php8.1-common php-json php8.1-gd php8.1-mbstring \
php8.1-curl php8.1-xml php8.1-intl libapache2-mod-php8.1 php8.1-mysql
(optional) Generate self-signed certificates
⚡ ⚡
Do not use this method in production. The certificates generated in this section will not be considered “safe” or “trusted” by your visitors’ web browers. Please use a certificate authority (such as Let’s Encrypt) to generate your server certificate. For those who’ll use LE, skip this section and go ahead to the mariaDB configuration.
Put your domain name in /etc/hosts
, for example:
$ echo "127.0.0.1 castopod.local" | sudo tee -a /etc/hosts
Generate the certificate and the corresponding private key for your domain (adapted from this article) :
$ openssl req -x509 -out castopod.local.crt -keyout castopod.local.key \
-newkey rsa:4096 -nodes -sha256 \
-subj '/CN=castopod.local' -extensions EXT -config <( \
printf "[dn]\nCN=castopod.local\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:castopod.local\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
Move the certificate and the private key to the following directories for example:
$ sudo mv castopod.local.crt /etc/ssl/certs/
$ sudo mv castopod.local.key /etc/ssl/private/
MariaDB server configuration
Start and enable the service:
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
Launch mariadb’s mysql_secure_installation
utility that helps improve your
database server security level a little:
$ sudo mysql_secure_installation
You’ll need to define a password for the database root user (blank by default) and keep the default choices for the other options.
Create castopod app database as well as a dedicated database user for castopod:
$ sudo mysql -u root -p
MariaDB [(none)]> CREATE DATABASE castopod_db;
MariaDB [(none)]> CREATE USER 'castopod_user'@localhost IDENTIFIED BY 'password1';
MariaDB [(none)]> GRANT CREATE, ALTER, DELETE, EXECUTE, INDEX, INSERT, SELECT, UPDATE ON castopod_db.* TO 'castopod_user'@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Change the dummy password given above and keep it somewhere safe…
Configure Apache
-
Download the latest Castopod archive, for example, as of today:
$ wget https://code.podlibre.org/podlibre/castopod-host/uploads/d979ccf46d8426ccdbb838d460698f7d/castopod-host-1.0.0-alpha.70.zip
⚡ ⚡
Download the “Castopod Host package”, not the “Source Code”. Both archives are available at the same place.
-
Extract Castopod Host code and copy it to the web server root folder:
$ unzip castopod-host-1.0.0-alpha.70.zip $ sudo cp -r castopod-host /var/www/html/castopod
-
Set the appropriate user ownership:
$ sudo chown -R www-data:www-data /var/www/html/castopod
-
Apache virtual host
-
If you chose to install Castopod with a self signed certificate, for testing purposes (not recommended in production), create a virtual host like the following. Do not forget to set the path to the certificate and key according to your setup (SSLCertificates… options):
$ cat /etc/apache2/sites-available/castopod.example.conf <IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin webmaster@localhost ServerName castopod ServerAlias castopod.local DocumentRoot /var/www/html/castopod/public LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on SSLCertificateFile /etc/ssl/certs/castopod.local.crt SSLCertificateKeyFile /etc/ssl/private/castopod.local.key <Directory /var/www/html/castopod/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> </IfModule>
Enable the newly created virtual host:
$ sudo a2ensite castopod-test.example.conf $ sudo systemctl reload apache2
-
If you chose to install Castopod with a Let’s Encrypt certificate, create an Apache virtual host like the following:
$ cat /etc/apache2/sites-available/castopod.example.conf <VirtualHost *:80> ServerName castopod.example.com DocumentRoot /var/www/html/castopod/public DirectoryIndex index.php index.html ErrorLog /var/log/apache2/error-castopod.log CustomLog /var/log/apache2/access-castopod.log common <Directory /var/www/html/castopod/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
Enable the newly created virtual host:
$ sudo a2ensite castopod-test.example.conf $ sudo systemctl reload apache2
Then use Certbot to generate the certificate and automatically adapt the Apache virtual host:
$ sudo certbot --apache
Certbot will ask questions: select your castopod domain name and activate automatic redirection to HTTPS.
Certbot installed the certificate and the associated private key in
/etc/letsencrypt/live/castopod.example.com
. It also created an Apache virtual host (with HTTPs) an modified the original Apache virtual host (created earlier) so that our users will automatically be redirected the HTTPs version of our castopod server. And that’s it, certbot did all the work! Here’s what the created Apache virtual host looks like:$ cat /etc/apache2/sites-available/castopod.example-le-ssl.conf <IfModule mod_ssl.c> <VirtualHost *:443> ServerName castopod.example.com DocumentRoot /var/www/html/castopod/public DirectoryIndex index.php index.html ErrorLog /var/log/apache2/error-castopod.log CustomLog /var/log/apache2/access-castopod.log common <Directory /var/www/html/castopod/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> SSLCertificateFile /etc/letsencrypt/live/castopod.example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/castopod.example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule>
-
-
Enable the required Apache modules:
$ sudo a2enmod ssl rewrite
-
Check that the required PHP extensions are enabled:
$ php -m
You should see curl, gd, intl, mbstring et mysqli in the list.
-
Check that the PHP version used by default is 8.0 or higher:
php -i | grep -i "PHP Version"
-
Restart Apache and enable it so that starts automatically at boot:
$ sudo systemctl restart apache2 $ sudo systemctl enable apache2
Finish the install using a web browser
Go to: https://castopod.local/cp-install for example (host name defined in the Apache virtual host configured above).
Note : It is recommended to change the default values of Admin gateway and Auth Gateway.
Troubleshooting
Which PHP version do you use ?
With the command php --ini
you can determine:
- Your default PHP version: should be 8.0 or higher for Castopod v1.0.0 alpha 70.
- The list of enabled PHP modules: see the list of required modules in castopod documentation.
- The path to the loaded PHP configuration file: useful if you want to edit the list of enabled PHP modules.
Apache logs
You can change the log lovel in the virtual host configuration:
/etc/apache2/sites-available/castopod.example.conf
(or HTTPs version).
In the example above, we had: LogLevel info ssl:warn
that we can change to
LogLevel debug ssl:warn
.
Don’t forget to reload the Apache service afterwards.
Events will be logged in (for example) /var/log/apache2/error.log
Castopod logs
You can increase the log verbosity level of Castopod. It is useful if you run into an error such as “We seem to have hit a snag. Please try again later.” in your web browser during the installation.
- Watch the logs here:
/var/www/html/castopod/writable/logs/
- Modify the log level in this file:
/var/www/html/castopod/.env
In the .env file, you can append the following line:
logger.threshold = 8
With this configuration item, Castopod is in debug mode. The log level can be set to one of the following values :
- 0 = Disables logging, Error logging TURNED OFF
- 1 = Emergency Messages - System is unusable
- 2 = Alert Messages - Action Must Be Taken Immediately
- 3 = Critical Messages - Application component unavailable, unexpected exception.
- 4 = Runtime Errors - Don’t need immediate action, but should be monitored.
- 5 = Warnings - Exceptional occurrences that are not errors.
- 6 = Notices - Normal but significant events.
- 7 = Info - Interesting events, like user logging in, etc.
- 8 = Debug - Detailed debug information.
- 9 = All Messages
Miscellaneous : Deleting a podcast
A few months ago it was not possible to delete a podcast from the castopod web interface. I managed to delete a podcast on the server I was hosting with the following commands. I’ll leave them here for the record (but they might no longer be useful as there’s been a few releases since then).
- Delete the database table entry that corresponds to your podcast:
SELECT id,name from cp_podcasts;
DELETE from cp_podcasts WHERE name="Podcast-Name" ;
- Delete the cache:
$ sudo rm /var/www/html/castopod-host/writable/cache/*
Conclusion
Now I’m going back to listening to podcasts. I hope all this will have helped some of you!