Skip to content

Deployment Overview of Paperless on Server

Prerequisites and Basic Requirements

To ensure a successful deployment, the following system requirements must be met:

  • Operating System: Ubuntu (recommended).

  • Privileges: Root or sudo access is required for package installation and service management.

  • System Dependencies:

  • Python 3, pip, venv, and dev packages.

  • Redis server.

  • OCR and document processing tools: tesseract-ocr, tesseract-ocr-rus, imagemagick, ghostscript, unpaper.

  • PDF and media libraries: libpoppler-cpp-dev, libmagic-dev, media-types, mailcap.

  • Fonts: fonts-liberation.

FQDN of the final panel on the hostkey.in domain

The application is accessible via a specific subdomain template.

Parameter Value
Prefix paperless-ngx
Domain hostkey.in
Full template paperless-ngx{Server_ID_from_Invapi}.hostkey.in

File and Directory Structure

The application uses the following directory structure for configuration, data, and system services:

  • /opt/paperless: Main application directory (version 2.20.15).

  • /opt/paperless/src: Application source code.

  • /opt/paperless/.venv: Python virtual environment.

  • /opt/paperless/data: Application data storage.

  • /opt/paperless/media: Media files storage.

  • /opt/paperless/consume: Directory for incoming documents to be processed.

  • /opt/paperless/export: Exported document storage.

  • /root/nginx: Nginx and Certbot configuration directory.

  • /data/nginx/user_conf.d: Custom Nginx user configurations.

  • /etc/systemd/system/: Systemd service files for Paperless components.

Application installation process

The application is installed using a combination of package management, manual extraction, and Python virtual environments:

  1. System Setup: The system updates the package cache and installs all required dependencies (Python, Redis, Tesseract, ImageMagick, etc.).

  2. User Creation: A dedicated system user named paperless is created with a home directory at /opt/paperless.

  3. Application Download: The Paperless-ngx v2.20.15 archive is downloaded from GitHub and extracted to /opt/paperless.

  4. Dependency Management:

  5. A Python virtual environment is initialized in /opt/paperless/.venv.

  6. Specific database backends (e.g., mysqlclient, psycopg-c) are removed from the requirements list to ensure compatibility with the local setup.

  7. All remaining dependencies are installed via pip within the virtual environment.

  8. Configuration: A configuration file paperless.conf is generated in /opt/paperless.

  9. Security Policy Adjustment: ImageMagick policy files are modified to allow the processing of PDF files.

  10. Database Initialization: Database migrations are executed using the Python management script within the virtual environment.

  11. Service Configuration: Systemd service units are created for the webserver, consumer, scheduler, and task queue.

Access Rights and Security

  • User Isolation: The application runs under a dedicated paperless system user to minimize security risks.

  • Permissions: Data directories (data, media, consume, export) are owned by the paperless user with appropriate permissions.

  • Firewall/Proxy: Access is managed via an Nginx proxy container that handles SSL termination.

Databases

The application utilizes a local Redis instance for task queuing and caching.

Component Connection Method Storage Location
Redis redis://localhost:6379 System-managed (via redis-server)

Docker Containers and Their Deployment

The deployment includes a containerized Nginx instance for SSL management.

Nginx Certbot Container

  • Image: jonasal/nginx-certbot:latest

  • Ports: Uses host networking (network_mode: host).

  • Volumes:

  • nginx_secrets:/etc/letsencrypt (External volume for SSL certificates)

  • /data/nginx/user_conf.d:/etc/nginx/user_conf.d

  • Environment Variables:

  • [email protected]

Custom Scripts and Additional Setup

The installation performs several specialized configuration steps:

  • Superuser Creation: An administrative user (root) is automatically created within the application to allow immediate web interface access.

  • Service Management: Four distinct systemd services are configured to manage different parts of the application lifecycle:

  • paperless-webserver: Handles HTTP requests via granian.

  • paperless-consumer: Processes documents.

  • paperless-scheduler: Manages scheduled tasks (Celery Beat).

  • paperless-task-queue: Manages the worker queue (Celery Worker).

Application Update Instructions

To update the main Paperless application, follow these steps:

  1. Download and extract the new version of Paperless-ngx to /opt/paperless.

  2. Re-run the Python dependency installation within the virtual environment:

    sudo -u paperless /opt/paperless/.venv/bin/pip install -r /opt/paperless/requirements.txt
    

  3. Run database migrations to update the schema:

    sudo -u paperless /opt/paperless/.venv/bin/python /opt/paperless/src/manage.py migrate
    

  4. Restart the services to apply changes:

    sudo systemctl restart paperless-webserver paperless-consumer paperless-scheduler paperless-task-queue
    

Location of configuration files and data

Type Path
Main Configuration /opt/paperless/paperless.conf
Data Directory /opt/paperless/data
Media Directory /opt/paperless/media
Consumption Directory /opt/paperless/consume
Export Directory /opt/paperless/export

Available ports for connection

  • HTTPS (External): 443 (via Nginx proxy)

  • HTTP (Internal Webserver): 3000

  • Redis: 6379

Starting and Stopping the application

The application components are managed via systemctl.

Starting all services:

sudo systemctl start paperless-webserver paperless-consumer paperless-scheduler paperless-task-queue

Stopping all services:

sudo systemctl stop paperless-webserver paperless-consumer paperless-scheduler paperless-task-queue

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×