>> 回到列表

派胜 ExpressOA Core v3.20 - 在 Linux 上使用 Systemd 托管

重要

ExpressOA Core v3.20 使用全球最佳编程语言 C# 构建(.NET 跨平台、高性能、开源免费)。
ExpressOA 包含自托管 Kestrel Web 服务器,Kestrel 可以单独使用,也可以与反向代理服务器一起使用。
ExpressOA 应用程序 runroot 文件夹中包含应用程序目录结构。
ExpressOA 在 Linux 上从 runroot/ExpressOA.dll 文件启动。
本文教程演示命令适用于 Ubuntu 24.04, 22.04, 20.04 Debian 12.x, 11.x openEuler 24.03 LTS, 22.03 LTS

(1)部署 ExpressOA 程序文件


1.1 下载 ExpressOA Core 程序包
https://www.paioffice.com/expressoa/downloads
Linux 命令
sudo unzip ExpressOA-Core-3.x.x.zip
解开 ExpressOA 程序包,移动 approot 到目标部署路径,例如 /expressoa。

1.2 安装字体
安装字体管理工具
适用于 Ubuntu 24.04, 22.04, 20.04Debian 12.x, 11.x
Linux 命令
sudo apt-get install fontconfig
适用于 openEuler 24.03 LTS, 22.03 LTS
Linux 命令
sudo dnf -y install fontconfig

复制 /expressoa/fonts 文件夹下的全部字体文件到 /usr/share/fonts。
Linux 命令
sudo cp -rf /expressoa/fonts/* /usr/share/fonts

更新字体
Linux 命令
sudo fc-cache -f -v

查看字体
Linux 命令
sudo fc-list

1.3 安装依赖程序
适用于 Ubuntu 24.04, 22.04, 20.04Debian 12.x, 11.x
Linux 命令
sudo apt-get update
sudo apt-get install xvfb
Linux 命令
sudo apt-get install -y libqt5webkit5
适用于 openEuler 24.03 LTS, 22.03 LTS
Linux 命令
sudo dnf -y install Xvfb
Linux 命令
sudo dnf -y install qt5-qtwebkit

1.4 设置 ExpressOA Core 目录结构的文件系统权限
ExpressOA Core v3.20 目录结构的文件系统权限列表如下。
目录/文件
文件系统权限
chmod 权限
用途
/fonts
只读
r--
字体文件
/license
读取、写入
rw-
存储许可证文件
/runroot
读取、执行
r-x
应用程序目录结构
/storageRoot
读取、写入
rw-
存储路径
/temp
读取、写入
rw-
临时文件夹
certarchive.json
只读
r--
数字存档证书配置
cloudstorage.json
只读
r--
云存储配置
database.json
只读
r--
配置数据库连接

执行 Linux 命令 chmod,设置文件系统权限。
Linux 命令
sudo chmod -R 444 /expressoa/fonts
sudo chmod -R 666 /expressoa/license
sudo chmod -R 555 /expressoa/runroot
sudo chmod -R 666 /expressoa/storageRoot
sudo chmod -R 666 /expressoa/temp
sudo chmod 444 /expressoa/certarchive.json
sudo chmod 444 /expressoa/cloudstorage.json
sudo chmod 444 /expressoa/database.json

(2)创建数据库结构

ExpressOA Core v3.20 支持数据库:Microsoft SQL Server、PostgreSQL、KingbaseES 和 MySQL。
ExpressOA 程序包 database-sql-statements 文件夹下,包含创建数据库结构的 SQL 语句。
lMicrosoft SQL Server 2022, 2019, 2017
lMicrosoft SQL Server Express 2022, 2019, 2017(免费商用)
lPostgreSQL 17, 16, 15, 14, 13, 12(免费商用)
lKingbaseES V8, V9
lMySQL 8.0+
lMariaDB 10.5+, 11.x

2.1 创建 Microsoft SQL Server 数据库结构。
使用 SQL Server 管理器,新建数据库 ExpressOA(数据库名称可以自定义)。
使用 SQL Server 管理器,选择数据库 >> 属性 >> 选项,确认数据库排序规则为 Chinese_PRC_CI_AS(简体中文)。
SQL Server 数据库 简体中文的排序规则
使用 SQL Server 查询分析器,创建 ExpressOA 数据库结构(依次执行 SQL 语句 microsoft-sqlserver....sql)。
1、系统核心数据结构。
microsoft-sqlserver_core.sql
2、 基本的演示工作流程(流程设计和表单模板)。
microsoft-sqlserver_demo.sql
3、可选。更多的演示工作流程(流程设计和表单模板)。
microsoft-sqlserver_workflow_sample.sql

2.2 创建 PostgreSQL 数据库结构。
使用 PostgreSQL 管理工具,创建 ExpressOA 数据库结构(依次执行 SQL 语句 postgresql....sql)。
1、系统核心数据结构。
postgresql_core.sql
2、基本的演示工作流程(流程设计和表单模板)。
postgresql_demo.sql
3、可选。更多的演示工作流程(流程设计和表单模板)。
postgresql_workflow_sample.sql

2.3 创建 KingbaseES 数据库结构。
使用 KingbaseES 管理工具,创建 ExpressOA 数据库结构(依次执行 SQL 语句 kingbase....sql)。
1、系统核心数据结构。
kingbase_core.sql
2、基本的演示工作流程(流程设计和表单模板)。
kingbase_demo.sql
3、可选。更多的演示工作流程(流程设计和表单模板)。
kingbase_workflow_sample.sql

2.4 创建 MySQL 数据库结构。
使用 MySQL 管理工具,创建 ExpressOA 数据库结构(依次执行 SQL 语句 mysql....sql)。
1、系统核心数据结构。
mysql_core.sql
2、基本的演示工作流程(流程设计和表单模板)。
mysql_demo.sql
3、可选。更多的演示工作流程(流程设计和表单模板)。
mysql_workflow_sample.sql

(3)配置数据库连接

编辑 database.json 配置数据库连接信息。
使用 SQL Server 数据库,DatabaseType 设置为【SQLServer】,【ConnectionStrings:SQLServer】配置 SQL Server 连接信息。
使用 PostgreSQL 数据库,DatabaseType 设置为【PostgreSQL】,【ConnectionStrings:PostgreSQL】配置 PostgreSQL 连接信息。
使用 KingbaseES 数据库,DatabaseType 设置为【KingbaseES】,【ConnectionStrings:KingbaseES】配置 KingbaseES 连接信息。
使用 MySQL(或 MySQL 兼容)数据库,DatabaseType 设置为【MySQL】,【ConnectionStrings:MySQL】配置 MySQL 连接信息。
重要:在 json 配置文件中,使用两个 \\ 代表一个 \。
例如:使用 SQL Server 数据库,DatabaseType 设置为【SQLServer】,【ConnectionStrings:SQLServer】配置 SQL Server 连接信息。
{
  "DatabaseType": "SQLServer",
  "ConnectionStrings": {
    "SQLServer": "database=ExpressOA;Data Source=localhost;User ID=sa;password=YourPassword;Connect Timeout=60;TrustServerCertificate=true",
    "PostgreSQL": "Database=ExpressOA;Host=localhost;Port=5432;Username=postgres;Password=YourPassword",
    "KingbaseES": "Database=ExpressOA;Host=localhost;Port=54321;Username=system;Password=YourPassword",
    "MySQL": "Database=ExpressOA;Server=localhost;Port=3306;User ID=root;Password=YourPassword"
  }
}

(4)在 Linux 上安装 ASP.NET Core 8.0

适用于 Ubuntu 24.04, 22.04, 20.04Debian 12.x, 11.x
Linux 命令
sudo apt-get update
sudo apt-get install -y aspnetcore-runtime-8.0
适用于 openEuler 24.03 LTS, 22.03 LTS
Linux 命令
sudo rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm
sudo dnf -y install aspnetcore-runtime-8.0

(5)配置 Kestrel Web 服务器

5.1 配置 Kestrel 绑定本机端口。
打开 runroot/appsettings.json,可以看到 Kestrel 默认绑定本机地址和端口 localhost:5000。
localhost 等于 127.0.0.1,使用 Kestrel 绑定本机地址和端口,可以与反向代理(Nginx, Apache)一起使用。
你可以自定义 Kestrel 绑定的端口(建议端口范围 5000-60000),只要该端口没有占用。
"Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      }
    }
  }

5.2 在 Linux 命令行中启动 Kestrel Web 服务器。
Linux 命令
sudo dotnet /expressoa/runroot/ExpressOA.dll

5.3 验证 Kestrel 是否正常工作。
Linux 命令
curl http://localhost:5000

(6)使用 Systemd 托管 ExpressOA

6.1 配置 Linux 后台服务 expressoa.service。
Systemd 是 Linux 系统工具,用来启动守护进程,已成为大多数 Linux 发行版的标准配置。
使用 vim 编辑 expressoa.service,把部署路径 /expressoa 修改为实际的部署路径。
Linux 命令
sudo vim /expressoa/runroot/expressoa.service

expressoa.service 文件模板
请根据你的实际配置,修改标记为红色的部分。
[Unit]
Description=ExpressOA

[Service]
WorkingDirectory=/expressoa/runroot
ExecStart=/usr/bin/dotnet /expressoa/runroot/ExpressOA.dll

Restart=always
RestartSec=10
SyslogIdentifier=expressoa
User=root
Environment=DOTNET_ROOT=/usr/lib64/dotnet
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

拷贝 runroot/expressoa.service 到 /etc/systemd/system。
Linux 命令
sudo cp /expressoa/runroot/expressoa.service /etc/systemd/system

6.2 启动服务 expressoa.service。
安装服务
Linux 命令
sudo systemctl enable /etc/systemd/system/expressoa.service

启动服务
Linux 命令
sudo systemctl start expressoa

重新加载配置(适用于修改 .service 服务配置文件之后)
Linux 命令
sudo systemctl daemon-reload

重启服务
Linux 命令
sudo systemctl restart expressoa

停止服务
Linux 命令
sudo systemctl stop expressoa

查看服务状态
Linux 命令
sudo systemctl status expressoa

(7)配置 Kestrel 独立提供服务

本章节演示配置 Kestrel 绑定域名和 SSL 证书,独立提供服务。
在验证 HTTPS 访问成功后,启用 HttpsRedirection 跳转。

7.1 使用 vim 编辑 runroot/appsettings.json 配置 Kestrel Web 服务器。
Linux 命令
sudo vim /expressoa/runroot/appsettings.json

Kestrel 绑定主机和端口
http://localhost:5000(http 监听本机网卡回环地址:5000 端口,只能在本机访问)
http://*:5000(http 监听所有 IP 地址:5000 端口)
http://oa.paioffice.com(http 监听本机所有 IP 地址:80 端口)
https://oa.paioffice.com(https 监听本机所有 IP 地址:443 端口)
appsettings.json 配置如下:
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://oa.paioffice.com"
      },
      "Https": {
        "Url": "https://oa.paioffice.com",
        "Certificate": {
          "Path": "/expressoa/oa.paioffice.com.pfx",
          "Password": "Your Password"
        }
      }
    }
  },
 "EnforcingSSL": {
    "HttpsRedirection": false,
    "UseHsts": false
  }

7.2 在 Linux 命令行中启动 Kestrel Web 服务器。
Linux 命令
sudo dotnet /expressoa/runroot/ExpressOA.dll

7.3 验证测试 HTTP 和 HTTPS 配置成功。
Linux 命令
curl http://oa.paioffice.com

Linux 命令
curl -4 https://oa.paioffice.com

7.4 将 HTTP 重定向到 HTTPS
使用 vim 编辑 runroot/appsettings.json,修改为 "HttpsRedirection": true。 重启 expressoa 服务。
Linux 命令
sudo systemctl restart expressoa



© 2018-2025 长春派胜科技有限公司 版权所有
吉公网安备22017202000417号