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, anddevpackages. -
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:
-
System Setup: The system updates the package cache and installs all required dependencies (Python, Redis, Tesseract, ImageMagick, etc.).
-
User Creation: A dedicated system user named
paperlessis created with a home directory at/opt/paperless. -
Application Download: The Paperless-ngx v2.20.15 archive is downloaded from GitHub and extracted to
/opt/paperless. -
Dependency Management:
-
A Python virtual environment is initialized in
/opt/paperless/.venv. -
Specific database backends (e.g.,
mysqlclient,psycopg-c) are removed from the requirements list to ensure compatibility with the local setup. -
All remaining dependencies are installed via
pipwithin the virtual environment. -
Configuration: A configuration file
paperless.confis generated in/opt/paperless. -
Security Policy Adjustment: ImageMagick policy files are modified to allow the processing of PDF files.
-
Database Initialization: Database migrations are executed using the Python management script within the virtual environment.
-
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
paperlesssystem user to minimize security risks. -
Permissions: Data directories (
data,media,consume,export) are owned by thepaperlessuser 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:
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 viagranian. -
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:
-
Download and extract the new version of Paperless-ngx to
/opt/paperless. -
Re-run the Python dependency installation within the virtual environment:
-
Run database migrations to update the schema:
-
Restart the services to apply changes:
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: