Nov 9, 2024 3 min read

Castopod: The Ultimate Self-Hosting Setup

Castopod: The Ultimate Self-Hosting Setup
Table of Contents

Castopod is an open-source, self-hosted podcasting platform designed for creators who value control, customization, and data ownership. It provides a robust set of features for managing and distributing podcasts while supporting modern podcasting standards such as ActivityPub for decentralized social networking. In this guide, we’ll walk through deploying, configuring, and managing Castopod, covering installation, Nginx setup, logging, backups, updates, and leveraging its unique features.

Installing Castopod

πŸ“¦ Docker/Docker Compose Setup

To deploy Castopod using Docker, create a docker-compose.yml file tailored for the app. This ensures proper container orchestration and persistent data storage.


version: '3.7'

services:

castopod:

image: adaurbroadcast/castopod:latest

container_name: castopod

ports:

- "8080:80"

environment:

- DB_HOST=db

- DB_DATABASE=castopod

- DB_USERNAME=castopod_user

- DB_PASSWORD=strongpassword

- BASE_URL=https://yourdomain.com

volumes:

- ./castopod_data:/var/www/html/storage

depends_on:

- db

db:

image: mysql:8.0

container_name: castopod_db

environment:

- MYSQL_ROOT_PASSWORD=rootpassword

- MYSQL_DATABASE=castopod

- MYSQL_USER=castopod_user

- MYSQL_PASSWORD=strongpassword

volumes:

- ./db_data:/var/lib/mysql

Save the file, then deploy Castopod using the following commands:


docker-compose up -d

This will spin up both the Castopod and MySQL containers. Replace placeholders in the docker-compose.yml file with your own domain name and secure passwords.

πŸš€ Manual Installation

For a manual setup on a Linux server, follow these steps:

  1. Install dependencies:

sudo apt update && sudo apt install -y php-fpm php-mysql curl unzip nginx mysql-server

  1. Download Castopod:

curl -L https://github.com/AdAUR/Castopod/archive/refs/heads/main.zip -o castopod.zip

unzip castopod.zip && mv Castopod-main /var/www/castopod

  1. Set permissions:

sudo chown -R www-data:www-data /var/www/castopod

sudo chmod -R 755 /var/www/castopod

  1. Configure MySQL:

mysql -u root -p -e "CREATE DATABASE castopod; CREATE USER 'castopod_user'@'localhost' IDENTIFIED BY 'strongpassword'; GRANT ALL PRIVILEGES ON castopod.* TO 'castopod_user'@'localhost'; FLUSH PRIVILEGES;"

  1. Run the Castopod installer by visiting the app in your browser at http://your-server-ip.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

Create an Nginx server block to route incoming traffic to Castopod:


server {

listen 80;

server_name yourdomain.com;

root /var/www/castopod/public;

index index.php index.html index.htm;

location / {

try_files $uri $uri/ /index.php?$query_string;

}

location ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

location ~ /\.ht {

deny all;

}

}

Test and enable the configuration:


sudo ln -s /etc/nginx/sites-available/castopod /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your app with Let's Encrypt by running:


sudo apt install certbot python3-certbot-nginx

sudo certbot --nginx -d yourdomain.com

Automate renewal with Cron:


echo "0 3 * * * certbot renew --quiet" | sudo tee -a /etc/crontab

Logging and Debugging Castopod

πŸ—ƒοΈ Enabling Debug Logs

To enable debugging, modify the .env file in the Castopod directory:


nano /var/www/castopod/.env

Set the logging level:


APP_DEBUG=true

LOG_LEVEL=debug

πŸ“„ Viewing Logs

If using Docker, view logs with:


docker logs castopod

For manual setups, logs are in:


tail -f /var/www/castopod/storage/logs/laravel.log

πŸ› οΈ Troubleshooting Common Issues

  • Database Connection Errors: Ensure .env has correct DB credentials.

  • Permission Errors: Verify /var/www/castopod ownership and permissions.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup application files:


tar -czvf castopod_backup.tar.gz /var/www/castopod

πŸ”„ Database Backups

Export the database:


mysqldump -u castopod_user -p castopod > castopod_db_backup.sql

Restore the database:


mysql -u castopod_user -p castopod < castopod_db_backup.sql

πŸ“… Automated Backup Scripts

Create a cron job for periodic backups:


echo "0 2 * * * tar -czvf /backups/castopod_$(date +\%F).tar.gz /var/www/castopod && mysqldump -u castopod_user -p'strongpassword' castopod > /backups/castopod_db_$(date +\%F).sql" | crontab -

Updating and Upgrading Castopod

⬆️ Updating Docker Images

Update to the latest version:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installs:


cd /var/www/castopod

git pull origin main

composer install --no-dev

php artisan migrate --force

πŸ” Checking for Updates

Visit the Castopod GitHub repository to monitor releases.

Leveraging Castopod’s Unique Features

πŸ”§ Enabling APIs

Enable the API in the .env file:


API_ENABLED=true

API_AUTH_TOKEN=yourapitoken

Test the API:


curl -H "Authorization: Bearer yourapitoken" https://yourdomain.com/api/podcasts

🌟 Advanced Configurations

To integrate with ActivityPub, enable federation:


ACTIVITYPUB_ENABLED=true

Reload the app:


php artisan cache:clear

php artisan config:cache

Wrapping Up

Self-hosting Castopod empowers you to manage your podcasting platform with full control and customization. From deployment to backups, this guide provides the technical steps needed to leverage its powerful features. Start implementing these examples now and take your podcasting endeavors to the next level.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.