Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:install_paperless-ngx_on_debian_without_docker [2026-08-17 19:17] – iacchi | en:install_paperless-ngx_on_debian_without_docker [2026-09-02 10:45] (current) – iacchi | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Install paperless-ngx on Debian without Docker ====== | ====== Install paperless-ngx on Debian without Docker ====== | ||
| - | Caveat: this guide assumes a non-Raspberry pi machine, and SQLite as database (which is ok for small installations). | + | Caveat: this guide assumes a non-Raspberry pi machine, and SQLite as database (which is ok for small installations). The service will be behind an Nginx proxy. |
| ===== Install dependencies and configure the system ===== | ===== Install dependencies and configure the system ===== | ||
| - | First, we'll need to install all required dependencies: | + | First, we'll need to install all required dependencies |
| <code bash> | <code bash> | ||
| - | apt install valkey-server python3 python3-pip python3-dev fonts-liberation imagemagick libmagic-dev poppler-utils build-essential python3-setuptools python3-wheel | + | apt install valkey-server python3 python3-pip python3-dev fonts-liberation imagemagick libmagic-dev poppler-utils build-essential python3-setuptools python3-wheel |
| </ | </ | ||
| Line 32: | Line 32: | ||
| cd / | cd / | ||
| sudo -u paperless wget https:// | sudo -u paperless wget https:// | ||
| - | sudo -u paperless tar -xf paperless-ngx-vx.x.x.tar.xz | + | sudo -u paperless tar xf paperless-ngx-vx.x.x.tar.xz |
| mv paperless-ngx/ | mv paperless-ngx/ | ||
| mv paperless-ngx/ | mv paperless-ngx/ | ||
| + | rmdir paperless-ngx | ||
| + | rm paperless-ngx-vx.x.x.tar.x | ||
| </ | </ | ||
| Line 45: | Line 47: | ||
| PAPERLESS_DATA_DIR | PAPERLESS_DATA_DIR | ||
| PAPERLESS_MEDIA_ROOT # If needed it can be the same directory as PAPERLESS_DATA_DIR | PAPERLESS_MEDIA_ROOT # If needed it can be the same directory as PAPERLESS_DATA_DIR | ||
| - | PAPERLESS_STATICDIR | + | PAPERLESS_STATICDIR=../static |
| PAPERLESS_SECRET_KEY | PAPERLESS_SECRET_KEY | ||
| PAPERLESS_URL | PAPERLESS_URL | ||
| PAPERLESS_OCR_LANGUAGE | PAPERLESS_OCR_LANGUAGE | ||
| PAPERLESS_TIME_ZONE | PAPERLESS_TIME_ZONE | ||
| + | PAPERLESS_USE_X_FORWARD_HOST=true | ||
| + | PAPERLESS_USE_X_FORWARD_PORT=true | ||
| + | PAPERLESS_PROXY_SSL_HEADER=' | ||
| </ | </ | ||
| - | Make sure you create the folders you have assigned in the config file and chown them to the paperless: | + | Make sure you create the folders you have assigned in the config file and chown them to the paperless: |
| <code bash> | <code bash> | ||
| + | sudo -u paperless makedir venv | ||
| + | sudo -u paperless python3 -m venv venv | ||
| + | sudo -u paperless venv/ | ||
| + | </ | ||
| + | Time to populate the database: | ||
| + | |||
| + | <code bash> | ||
| + | cd src | ||
| + | sudo -u paperless ../ | ||
| </ | </ | ||
| + | As a last installation step, something undocumented on paperless-ngx' | ||
| + | < | ||
| + | PAPERLESS_ENABLE_NLTK=true | ||
| + | PAPERLESS_NLTK_DIR=/ | ||
| + | </ | ||
| + | |||
| + | Then, download the required packages: | ||
| <code bash> | <code bash> | ||
| + | cd / | ||
| + | sudo -u paperless venv/ | ||
| + | sudo -u paperless venv/ | ||
| + | sudo -u paperless venv/ | ||
| + | </ | ||
| + | Before testing the server to see if it works, we need to temporarily enable debug mode. Add '' | ||
| + | |||
| + | <code bash> | ||
| + | cd src | ||
| + | sudo -u paperless ../ | ||
| </ | </ | ||
| + | It's now time to set up all the systemd services. Script examples are in the '' | ||
| + | paperless-consumer.service | ||
| + | < | ||
| + | [Unit] | ||
| + | Description=Paperless consumer | ||
| + | Requires=redis.service | ||
| - | <code bash> | + | [Service] |
| + | User=paperless | ||
| + | Group=paperless | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| </ | </ | ||
| + | paperless-scheduler.service | ||
| + | < | ||
| + | [Unit] | ||
| + | Description=Paperless Celery Beat | ||
| + | Requires=redis.service | ||
| + | [Service] | ||
| + | User=paperless | ||
| + | Group=paperless | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| - | < | + | [Install] |
| + | WantedBy=multi-user.target | ||
| + | </code> | ||
| + | |||
| + | paperless-task-queue.service | ||
| + | < | ||
| + | [Unit] | ||
| + | Description=Paperless Celery Workers | ||
| + | Requires=redis.service | ||
| + | |||
| + | [Service] | ||
| + | User=paperless | ||
| + | Group=paperless | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| </ | </ | ||
| + | paperless-webserver.service | ||
| + | < | ||
| + | [Unit] | ||
| + | Description=Paperless webserver | ||
| + | After=network.target | ||
| + | Wants=network.target | ||
| + | Requires=valkey.service | ||
| + | # | ||
| + | [Service] | ||
| + | User=paperless | ||
| + | Group=paperless | ||
| + | WorkingDirectory=/ | ||
| - | <code bash> | + | Environment=GRANIAN_HOST=:: |
| + | Environment=GRANIAN_PORT=8000 | ||
| + | Environment=GRANIAN_WORKERS=1 | ||
| + | |||
| + | ExecStart=/ | ||
| + | # Host: GRANIAN_HOST -> PAPERLESS_BIND_ADDR -> default \ | ||
| + | [ -n " | ||
| + | # Port: GRANIAN_PORT -> PAPERLESS_PORT -> default \ | ||
| + | [ -n " | ||
| + | # Workers: GRANIAN_WORKERS -> PAPERLESS_WEBSERVER_WORKERS -> default \ | ||
| + | [ -n " | ||
| + | # URL path prefix: only set if PAPERLESS_FORCE_SCRIPT_NAME exists \ | ||
| + | [ -n " | ||
| + | exec / | ||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| </ | </ | ||
| + | Now that we have the unit files ready, we need to enable and start them: | ||
| <code bash> | <code bash> | ||
| + | cd scripts | ||
| + | systemctl enable paperless-task-queue.service | ||
| + | systemctl enable paperless-scheduler.service | ||
| + | systemctl enable paperless-consumer.service | ||
| + | systemctl enable paperless-server.service | ||
| + | systemctl start paperless-task-queue.service | ||
| + | systemctl start paperless-scheduler.service | ||
| + | systemctl start paperless-consumer.service | ||
| + | systemctl start paperless-server.service | ||
| + | </ | ||
| + | All that is left to do now is configure the Nginx reverse proxy: | ||
| + | |||
| + | <code bash> | ||
| + | cd / | ||
| + | nano docs.mydomain.tld | ||
| </ | </ | ||
| + | This is the content of the docs.mydomain.tld file: | ||
| + | < | ||
| + | server { | ||
| + | listen 443 ssl; | ||
| + | listen [::]:443 ssl; | ||
| + | http2 on; | ||
| + | ssl_certificate | ||
| + | ssl_certificate_key / | ||
| + | server_name docs.mydomain.tld; | ||
| + | access_log / | ||
| + | error_log | ||
| + | client_max_body_size 20M; | ||
| - | <code bash> | + | large_client_header_buffers 4 8k; |
| + | add_header Strict-Transport-Security " | ||
| + | add_header X-Content-Type-Options nosniff; | ||
| + | add_header X-XSS-Protection "1; mode=block"; | ||
| + | add_header X-Robots-Tag none; | ||
| + | add_header X-Download-Options noopen; | ||
| + | add_header X-Permitted-Cross-Domain-Policies none; | ||
| + | location = / | ||
| + | proxy_pass http:// | ||
| + | proxy_http_version 1.1; | ||
| + | proxy_set_header Upgrade $http_upgrade; | ||
| + | proxy_set_header Connection " | ||
| + | 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; | ||
| + | proxy_set_header X-Forwarded-Proto $scheme; | ||
| + | proxy_hide_header Referrer-Policy; | ||
| + | add_header Referrer-Policy " | ||
| + | } | ||
| + | |||
| + | location / { | ||
| + | proxy_pass http:// | ||
| + | proxy_http_version 1.1; | ||
| + | proxy_set_header Upgrade $http_upgrade; | ||
| + | proxy_set_header Connection " | ||
| + | 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; | ||
| + | proxy_set_header X-Forwarded-Proto $scheme; | ||
| + | proxy_hide_header Referrer-Policy; | ||
| + | add_header Referrer-Policy " | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
| + | And now it's time to enable the configuration: | ||
| <code bash> | <code bash> | ||
| + | ln -s / | ||
| + | systemctl restart nginx | ||
| </ | </ | ||
| + | ===== Updating paperless-ngx ===== | ||
| + | Paperless-ngx' | ||
| <code bash> | <code bash> | ||
| + | systemctl stop paperless-consumer paperless-scheduler paperless-task-queue paperless-webserver | ||
| + | cd /opt | ||
| + | cp -R paperless paperless.bak | ||
| + | wget https:// | ||
| + | tar xf paperless-ngx-vx.x.x.tar.xz | ||
| + | chown -R paperless: | ||
| + | </ | ||
| + | At this point it's good to stop for a second and check that the systemd unit files in the '' | ||
| + | |||
| + | <code bash> | ||
| + | cd / | ||
| + | rm -r `ls -a | grep -v " | ||
| + | cd / | ||
| + | rm -r .env paperless.conf scripts | ||
| + | mv ./* ../ | ||
| </ | </ | ||
| + | Now, with all the files in place, we update the python dependencies. In principle we should also manually remove all dependencies that are no longer required, but meh, we'll think about it if errors occur. | ||
| + | <code bash> | ||
| + | cd / | ||
| + | sudo -u paperless venv/ | ||
| + | cd src | ||
| + | sudo -u paperless ../ | ||
| + | sudo -u paperless ../ | ||
| + | sudo -u paperless ../ | ||
| + | </ | ||
| + | |||
| + | It is now possible to restart the services. | ||
| <code bash> | <code bash> | ||
| + | systemctl start paperless-consumer paperless-scheduler paperless-task-queue paperless-webserver | ||
| + | </ | ||
| + | If everything works, we can clean up: | ||
| + | |||
| + | <code bash> | ||
| + | cd /opt | ||
| + | rm -R paperless.bak paperless-ngx | ||
| </ | </ | ||