当前位置: 首页 > news >正文

Paperless-ngx v2.18.4在Ubuntu 24.04上的完整离线安装步骤(非Docker)

​1. 系统准备与依赖安装​

首先更新系统并安装基础工具,确保后续步骤顺利进行:

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git build-essential

安装Python环境及开发工具(Paperless-ngx基于Python 3开发):

sudo apt install -y python3 python3-pip python3-dev python3-venv

安装数据库(PostgreSQL,推荐用于生产环境,性能更优):

sudo apt install -y postgresql postgresql-contrib libpq-dev

安装OCR工具链(用于文档文字识别,支持中文等多语言):

sudo apt install -y imagemagick fonts-liberation gnupg libmagic-dev libzbar0 poppler-utils unpaper ghostscript icc-profiles-free qpdf liblept5 libxml2 pngquant zlib1g tesseract-ocr tesseract-ocr-chi-sim tesseract-ocr-chi-tra

安装Redis(消息队列,提升文档处理性能):

sudo apt install -y redis-server
sudo systemctl enable --now redis-server  # 启用并启动Redis服务
​2. 上传Paperless-ngx源码​

将​​能联网的机器​​上下载的Paperless-ngx v2.18.4源码包(如paperless-ngx-v2.18.4.zip)解压后,通过U盘、SFTP等工具上传到目标服务器的/opt目录。例如:

# 在能联网的机器上打包源码
cd ~/paperless-ngx-v2.18.4
zip -r ../paperless-ngx-v2.18.4.zip .# 传输到目标服务器(假设U盘挂载在/mnt/usb)
sudo mount /dev/sdb1 /mnt/usb
cp ../paperless-ngx-v2.18.4.zip /mnt/usb/
sudo umount /mnt/usb# 在目标服务器上解压
cd /opt
sudo unzip paperless-ngx-v2.18.4.zip
sudo mv paperless-ngx-v2.18.4 paperless-ngx  # 重命名目录
sudo chown -R paperless:paperless /opt/paperless-ngx  # 设置目录所有权
​3. 下载并安装系统依赖​

在目标服务器上,使用apt下载Paperless-ngx所需的系统依赖(确保网络畅通):

sudo apt install -y python3 python3-pip python3-dev python3-venv \postgresql postgresql-contrib libpq-dev \imagemagick fonts-liberation gnupg libmagic-dev libzbar0 poppler-utils unpaper ghostscript icc-profiles-free qpdf liblept5 libxml2 pngquant zlib1g tesseract-ocr \redis-server
​4. 配置数据库​

切换至PostgreSQL用户,创建数据库及专用用户(避免使用默认用户):

sudo -u postgres psql

在PostgreSQL交互界面中执行以下命令(替换your_secure_password为强密码,注意密码中不要有@符号,会导致后面数据库密码验证出问题):

CREATE DATABASE paperless WITH ENCODING='UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8';
CREATE USER paperless WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE paperless TO paperless;
\q  # 退出PostgreSQL
​5. 处理配置文件位置变更(v2.18.4默认根目录)​

Paperless-ngx v2.18.4将paperless.conf文件默认放在​​项目根目录​​(即/opt/paperless-ngx/)下,而非之前的config/目录。进入项目目录,复制配置模板(若源码中无paperless.conf.example,需从其他已下载的源码中获取):

cd /opt/paperless-ngx
cp paperless.conf.example paperless.conf  # 若无example文件,需手动创建(见下一步)

​若源码中无paperless.conf.example​,手动创建paperless.conf并填入以下基本配置(根据你的环境修改):

# ===== 数据库配置(PostgreSQL) =====
PAPERLESS_DBENGINE=postgres
PAPERLESS_DBHOST=localhost
PAPERLESS_DBPORT=5432
PAPERLESS_DBNAME=paperless
PAPERLESS_DBUSER=paperless
PAPERLESS_DBPASS=your_secure_password  # 替换成你的PostgreSQL密码# ===== Redis配置 =====
PAPERLESS_REDIS=redis://localhost:6379/0# ===== 存储路径 =====
PAPERLESS_CONSUMPTION_DIR=/opt/paperless/consume  # 文档扫描/导入目录
PAPERLESS_MEDIA_ROOT=/opt/paperless/media         # 文档存储目录
PAPERLESS_EXPORT_DIR=/opt/paperless/export        # 导出目录# ===== 安全配置 =====
PAPERLESS_SECRET_KEY=$(openssl rand -hex 32)  # 生成随机密钥(或手动设置一个)
PAPERLESS_TIME_ZONE=Asia/Shanghai             # 时区(中国)# ===== 其他可选配置 =====
PAPERLESS_ALLOW_REGISTRATION=False  # 是否允许新用户注册(生产环境建议False)
PAPERLESS_AUTO_LOGIN=False          # 是否自动登录(生产环境建议False)
​6. 创建必要目录并设置权限​

创建文档存储、导入及导出目录,并设置正确的权限(确保paperless用户可访问):

sudo mkdir -p /opt/paperless/{consume,media,export}
sudo chown -R paperless:paperless /opt/paperless
​7. 安装Python依赖​

使用虚拟环境隔离项目依赖,避免污染系统环境:

# 创建虚拟环境
sudo -u paperless python3 -m venv /opt/paperless-ngx/venv# 激活虚拟环境并升级pip
source /opt/paperless-ngx/venv/bin/activate
pip install --upgrade pip setuptools wheel# 安装Python依赖(从requirements.txt)
pip install -r /opt/paperless-ngx/requirements.txt
​8. 初始化数据库与创建管理员​

执行数据库迁移(创建表结构):

cd /opt/paperless-ngx/src
sudo -u paperless python3 manage.py migrate

创建超级用户(用于登录Web界面,按提示输入用户名、密码及邮箱):

sudo -u paperless python3 manage.py createsuperuser
​9. 配置系统服务(开机自启)​

创建systemd服务文件(paperless提供样本在scripts文件夹中,可以直接复制过来然后修改对应的路径参数等),实现Paperless-ngx的自动启动与管理:

sudo nano /etc/systemd/system/paperless.service

写入以下内容(替换/opt/paperless-ngx/src为你的项目路径):

[Unit]
Description=Paperless-ngx Document Management System
After=network.target redis.service postgresql.service[Service]
User=paperless
Group=paperless
WorkingDirectory=/opt/paperless-ngx/src
Environment="PATH=/opt/paperless-ngx/src/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/opt/paperless-ngx/src/venv/bin/python3 manage.py runserver 0.0.0.0:8000
Restart=always  # 服务崩溃时自动重启[Install]
WantedBy=multi-user.target

启用并启动服务:

sudo systemctl start 服务名
sudo systemctl enable --now 服务名  # 设置开机自启并立即启动

或者

sudo systemctl daemon-reload
sudo systemctl enable --now paperless  # 设置开机自启并立即启动
​10. 访问Web界面​

等待服务启动完成后(可通过sudo systemctl status paperless查看状态),通过浏览器访问http://your_server_ip:8000(若未配置域名,可使用服务器IP)。首次登录时,使用之前创建的超级用户账号和密码进行登录。

​后续操作建议​​:

  • /opt/paperless/consume(文档元数据)和/opt/paperless/media(文档文件)目录加入定期备份计划(如使用rsynccron)。
  • 若需更高性能,可调整Redis缓存大小(修改/etc/redis/redis.conf中的maxmemory参数)或升级服务器硬件(推荐SSD存储)。
  • 配置邮件通知(如文档上传提醒),需修改paperless.conf中的邮件相关参数(如PAPERLESS_MAIL_HOSTPAPERLESS_MAIL_USER等)。

文章转载自:

http://l7eZDaK2.fthqc.cn
http://knVGryzj.fthqc.cn
http://71TCQIjF.fthqc.cn
http://eJrpdyfw.fthqc.cn
http://2PMK8x5b.fthqc.cn
http://W54DEQAJ.fthqc.cn
http://1uQXS3Ir.fthqc.cn
http://9jQd1kxl.fthqc.cn
http://kFUbai2c.fthqc.cn
http://6bWypNuQ.fthqc.cn
http://LdmB9JCa.fthqc.cn
http://9vfbNPcW.fthqc.cn
http://XLnMLCCw.fthqc.cn
http://rtPTMXb6.fthqc.cn
http://blSjVuO7.fthqc.cn
http://igDqXD3A.fthqc.cn
http://4BZ5w5m7.fthqc.cn
http://ZaYIMVrY.fthqc.cn
http://l3WGL4dm.fthqc.cn
http://1wg5s86j.fthqc.cn
http://q61bxsNe.fthqc.cn
http://mOwxvp5m.fthqc.cn
http://s9YfiNxJ.fthqc.cn
http://F621LlaA.fthqc.cn
http://PSYKOZsY.fthqc.cn
http://WFEtGouG.fthqc.cn
http://NBqbbPcq.fthqc.cn
http://WYo08E0l.fthqc.cn
http://ZtgpRboG.fthqc.cn
http://Da7THXgI.fthqc.cn
http://www.dtcms.com/a/387344.html

相关文章:

  • Ubuntu 18.04 搭建 Kubernetes 1.27.4 集群全流程(附问题排查)
  • Ubuntu 18.04 LTS 安装 6.10.10 内核
  • Windows 11 下使用 WSL2 安装 Ubuntu 22.04 步骤
  • 在 WSL 中通过 Bash 函数快速转换 Windows 路径为 Ansible/WSL 路径
  • 【ubuntu24.04】 nvidia-smi监控GPU 利用率
  • 《嵌入式硬件(十四):基于IMX6ULL的通用目的定时器(GPT)操作》
  • 鸿蒙Next Web调试与维测全攻略:从DevTools到专项测试
  • 基于运行设计域(ODD)的安全论证方法
  • 鸿蒙HarmonyOS界面开发-组件动态创建(一)
  • 网络安全风险评估中元模型构建与实例应用
  • 鸿蒙5.0应用开发——V2装饰器@ObservedV2和@Trace的使用
  • xkInfoScan 是一款集成化的网络信息收集与安全扫描工具,支持 IP / 域名 / URL /信息追踪多维度目标探测
  • 解决 Windows 系统下 TDengine 数据恢复及迁移问题
  • PocketBase 是一个‌开源的轻量级后端框架‌,基于 Go 语言开发
  • 苹果新手机和旧手机怎么传输数据?新手避坑指南
  • Maven 只打包部分模块,跳过单元测试... 常用打包参数
  • 【maven01】依赖管理的工具
  • BP神经网络多输入多输出回归预测+SHAP可解释分析+新数据预测(MATLAB完整源码)
  • MATLAB 时间序列小波周期分析
  • 计算机视觉进阶教学之DNN模块
  • 大模型无需懂MCP:工具调用范式的架构革命与实践指南
  • 剑指offer题单 9.14
  • IIS 站点 http 请求412问题解决
  • Web前端入门:从零开始做网站(视频教程)
  • 本地--Oracle表被锁了该如何处理
  • Doris与Clickhouse分析
  • ByteDance字节前端一面
  • 卫星通信+AI双核驱动,遨游智能三防手机连得上、会思考
  • 云手机通道具有哪些方面的优势
  • 前端实验(二)初识Vue