Skip to content

Install_FreeBSD14

Chris Caron edited this page May 10, 2025 · 2 revisions

📦 Installing and Running Apprise API on FreeBSD

This guide walks you through installing Apprise API on FreeBSD, without Docker. It also configures the service to run persistently using FreeBSD’s native rc.d system.

🛠️ Prerequisites

Install required packages:

sudo pkg install python39 py39-pip git

Verify installations:

python3.9 --version
pip3.9 --version
git --version

📥 Step 1: Clone and Prepare Apprise API

cd /usr/local
sudo git clone https://github.com/caronc/apprise-api.git
cd apprise-api

# Optional: Set proper ownership
sudo chown -R www:www .

🐍 Step 2: Set Up Virtual Environment

python3.9 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

🔧 Step 3: Create rc.d Startup Script

Create the service script:

sudo vi /usr/local/etc/rc.d/apprise

Paste this:

#!/bin/sh

# PROVIDE: apprise
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name=apprise
rcvar=apprise_enable

load_rc_config $name

: ${apprise_enable:="NO"}
: ${apprise_user:="www"}
: ${apprise_group:="www"}
: ${apprise_dir:="/usr/local/apprise-api"}
: ${apprise_venv:="${apprise_dir}/venv"}
: ${apprise_pidfile:="/var/run/${name}.pid"}
: ${apprise_logfile:="/var/log/${name}.log"}

pidfile=${apprise_pidfile}
command="/usr/sbin/daemon"
command_args="-p ${pidfile} -o ${apprise_logfile} -u ${apprise_user} -t ${name} ${apprise_venv}/bin/gunicorn apprise_api.wsgi:application --chdir ${apprise_dir} --bind 127.0.0.1:8000"

run_rc_command \"$1\"

Make it executable:

sudo chmod +x /usr/local/etc/rc.d/apprise

🔁 Step 4: Enable the Service on Boot

sudo sysrc apprise_enable=YES

▶️ Step 5: Start the Apprise API Service

sudo service apprise start

🌐 Step 6: Configure NGINX Reverse Proxy for Static Files

Edit or create the file:

sudo vi /usr/local/etc/nginx/nginx.conf

Use this structure (based on official example):

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  your.server.com;

        location /static/ {
            alias /usr/local/apprise-api/static/;
        }

        location / {
            proxy_pass         http://127.0.0.1:8000;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    }
}

Enable and start NGINX:

sudo sysrc nginx_enable=YES
sudo service nginx start

🧪 Step 7: Access Website

Visit https://127.0.0.1 and see if the Apprise API loads up okay.

🗂️ Log and Runtime Files

  • Apprise API log: /var/log/apprise.log
  • PID file: /var/run/apprise.pid
  • Static files: /usr/local/apprise-api/static/

Ensure the user (www by default) has permission to access/write these.

🧼 Service Management Commands

sudo service apprise start
sudo service apprise stop
sudo service apprise restart
sudo service nginx restart