rConfig 8.2.19 Ubuntu 22.04 安装指南

在 Ubuntu 22.04 服务器上从零安装 rConfig V8 Core 8.2.19 的完整实操指南:官方脚本与手动安装双方案、七步主程序部署、真实排障实录与验证清单,全部命令实测。

rConfigrConfig网络管理2026/10/28

rConfig 8.2.19 Ubuntu 22.04 安装指南

目标:在一台全新 Ubuntu 22.04 服务器上从零安装 rConfig V8 Core 8.2.19(开源版),完成数据库、Web 服务器、队列进程与计划任务的全部配置,并首次登录 Web 控制台。本文全部命令与回显已在 Ubuntu 22.04.5 LTS(x86_64)环境中实测通过。

一、环境信息

本文以「单台 Ubuntu 22.04 服务器」为部署目标,采用 Apache + MariaDB + PHP + Redis + Supervisor 的经典组合(rConfig 官方称 LAMP Stack Installer 一键脚本安装的就是这一套)。实测环境关键信息如下:

项目实测值
操作系统Ubuntu 22.04.5 LTS(x86_64)
rConfig 版本V8 Core 8.2.19(2026-10-27 发布,开源主线最新稳定版)
PHP8.4.27(NTS,CLI + libapache2-mod-php8.4)
Laravel 框架13.38.0
Web 服务器Apache 2.4.52(Ubuntu)
数据库MariaDB 11.2.6
Redis6.0.16(队列与缓存后端)
进程管理Supervisor 4.2.1(托管 Horizon 队列)
Composer2.10.3
git2.34.1
安装路径/var/www/html/rconfig
监听端口80(Apache);3306(MariaDB);6379(Redis,仅本机)
磁盘占用(实测)应用目录 186M(其中 vendor 91M)、MariaDB 数据目录初始化后约 160M
内存占用(实测)全栈空载运行时系统总内存占用约 9.5 GiB(含系统与其他服务),4 GiB 内存服务器可满足小规模使用

⚠️ 下载渠道说明:本文写作时(2026-10-28),rConfig 官方脚本下载源 https://dl.rconfig.com 与 Composer 官方源 https://getcomposer.org 直连可用;GitHub 仓库克隆 https://github.com/rconfig/rconfig.git 直连超时,实测走代理 192.168.1.62:7897 可用(见 6.2 节)。若你的网络环境不同,请按实际可用渠道调整。

二、前置条件

rConfig V8 Core 官方支持的操作系统为:Rocky Linux 8/9+(官方推荐)、CentOS 8/9+、RHEL 8/9+、Ubuntu 22.04 或 24.04(26.04 暂不支持)、AlmaLinux 8/9+。本文聚焦 Ubuntu 22.04。

安装前请确认以下条件:

  1. 一台全新安装的 Ubuntu 22.04 服务器,具备 root 或 sudo 权限;
  2. 服务器可访问互联网(下载系统包、PHP 扩展、Composer 依赖与 rConfig 源码);
  3. 约 30~45 分钟的安装时间;
  4. 基本的 Linux 命令行操作能力;
  5. 磁盘可用空间建议 5 GB 以上(应用目录实测约 186M,加上 MariaDB 数据目录、系统包与日志余量)。

💡 说明:rConfig 还提供 V8 Pro 商业版与基于其他 Web 服务器的部署方式,本文只覆盖官方开源版 V8 Core 在 Ubuntu 22.04 上的标准安装(Apache 形态)。

三、版本选型说明

rConfig 历史上存在 v3 与 v8 两条产品线:v3 已于 2023 年 2 月官方宣布弃用(仅安全修复,不再开发),当前开源主线是 V8 Core,商业版为 V8 Pro。新装一律选 V8 Core。

选型依据的版本信息实测如下:

# 查看已安装的 rConfig 版本(安装完成后)
cat /var/www/html/rconfig/VERSION

实测回显:

8.2.19
# 查看应用版本(Laravel artisan 视角)
cd /var/www/html/rconfig && php artisan --version

实测回显:

Laravel Framework 13.38.0
# 查看 composer.json 中声明的运行环境要求
grep -E '"version"|"php"|"laravel/framework"' /var/www/html/rconfig/composer.json

实测回显:

    "version": "8.2.19",
        "php": "^8.4.27|^8.3.36|^8.2.35",
        "laravel/framework": "^13.0",

关键结论:

  • 当前最新稳定版为 8.2.19(CHANGELOG 中对应 ## [8.2.19] - 2026-10-27);
  • PHP 支持范围为 8.2.35 / 8.3.36 / 8.4.27 及以上补丁版本,官方脚本默认安装 PHP 8.4,与要求匹配;
  • 发行节奏较快(近期 8.2.16 → 8.2.17 → 8.2.18 → 8.2.19 连续发布),安装后建议关注官方 Update Process 文档定期升级,升级由仓库自带的 ./update.sh 完成,不在本文展开。

💡 技术拓展:PHP 运行形态常见两种选择——

形态原理/特点适用场景
mod_php(libapache2-mod-php)PHP 作为 Apache 模块内嵌运行,配置简单单机一体化部署,本文采用
PHP-FPM + 反向代理PHP 独立进程池,Apache/Nginx 通过 FastCGI 转发,资源隔离更好多站点共存、需要独立调优进程池

rConfig 官方 Ubuntu 脚本采用 mod_php 形态,安装即用;若服务器上还需承载其他 PHP 站点,可自行切换为 PHP-FPM,但需自行配置虚拟主机转发,不在官方脚本覆盖范围内。

四、方案 A:官方脚本自动安装基础环境(推荐)

4.1 方案说明

rConfig 官方为各发行版提供了 OS Configuration 自动化脚本(Ubuntu 版为 rconfig8_ubuntu.sh),一次性完成 11 个步骤:系统更新、基础包安装、cron、Redis 与 Supervisor、LAMP(Apache + MariaDB 11.2 + PHP 8.4)、防火墙、Composer、版本校验、登录脚本部署、MariaDB 安全初始化。这是官方推荐路径,全程约 10~20 分钟(视网络速度)。

脚本只负责「基础环境」,rConfig 主程序本身仍需按第六章手动部署。

4.2 下载并运行官方脚本

按官方 OS Configuration 文档的 Ubuntu 段落执行:

cd /home
apt-get -y install wget
wget https://dl.rconfig.com/downloads/rconfig8_ubuntu.sh -O /home/install.sh
chmod +x install.sh

脚本接受一个可选参数作为 MariaDB root 密码:传入则自动完成 mariadb-secure-installation(应答序列为:切换 unix_socket 认证 y、设置 root 密码两次、删除匿名用户 y、禁止 root 远程 y、删除 test 库 y、刷新权限 y);不传参数则在第 10 步进入交互式安全初始化向导。本文实测采用传入密码方式(演示口令 q1w2e3r4):

./install.sh q1w2e3r4

实测输出(11 步全量较长,以下为各步骤起止节选,实测首尾照抄):

==================================================================
 rConfig LAMP Stack Installer for Ubuntu
==================================================================

[i]  Initializing installation process...
[✓] Running as root user
[i]  OS Installation script starting...!

[Step 1/11] Updating Operating System
[i]  Starting OS update... please wait!
[✓] OS update completed!

[Step 2/11] Installing Base Packages
[i]  Starting base package installation... please wait!
[✓] Base package installation completed!

[Step 3/11] Installing and Starting Cron Service
[✓] Cron installed successfully.
[✓] Cron service is active.
[✓] Cron installation and setup complete.

[Step 4/11] Installing Redis and Supervisor
[✓] Redis and Supervisor installation completed!

[Step 5/11] Installing LAMP Stack (Apache, MariaDB, PHP)
[✓] Finished LAMP Installation... so far so good!

[Step 6/11] Opening Firewall Ports
[✗]  UFW is not running!

⚠️ 注意:[✗] UFW is not running! 不是失败——脚本检测到 UFW 防火墙未启用时跳过放行步骤。如果你的服务器启用了 UFW,脚本会自动放行 SSH/HTTP/HTTPS;若 UFW 未启用而服务器有云安全组,请在安全组放行 80/443 端口。

续前输出(Composer 与版本校验步骤):

[Step 7/11] Installing Composer
Composer (version 2.10.3) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
[✓] Composer installation completed!
[Step 8/11] Verifying Installed Software Versions
[i]  Checking installed software versions...
[✓] PHP version: 8.4.27
[✓] Apache version:  Apache/2.4.52 (Ubuntu)
[✓] MySQL version: 11.2.6-MariaDB
[✓] Redis version: 6.0.16
[✓] Supervisor version: 4.2.1
[✓] Zip: Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
[✓] Unzip: UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.
[✓] Cron: ii  cron                          3.0pl1-137ubuntu3                       amd64        process scheduling daemon
[✓] Btop: btop version: 1.2.3
[✓] Vim: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug 24 2026 22:13:24)

[Step 9/11] Deploying rConfig Login Script
[i]  Downloading rConfig login script...
[✓] rConfig login script deployed!

[Step 10/11] Running MariaDB Secure Installation
[i]  Preparing for MariaDB secure installation...
[i]  This step will help secure your MariaDB installation.
Thanks for using MariaDB!

[Step 11/11] All installation steps completed successfully!
[✓] Installation complete, a reboot is always a good idea at this point.
[i]  Go back to the rConfig 8 documentation and follow the instructions to continue the deployment.

脚本内部对 LAMP 的处理(便于理解其行为,无需手动执行):MariaDB 通过官方仓库脚本 mariadb_repo_setup --mariadb-server-version=11.2 安装 11.2 系列并启用服务;PHP 通过 ppa:ondrej/php 源安装 8.4 全套扩展(gd/curl/mysql/ldap/zip/mbstring/gmp/xml/snmp 与 libapache2-mod-php8.4);Redis、Supervisor、cron 走 Ubuntu 官方源。

⚠️ 排障实录:在极度精简的系统上(未预装 sudo),脚本会在每一步报 sudo: command not found 并在第 3 步因装不上 cron 而退出。解决:先执行 apt-get update && apt-get install -y sudo,再重新运行脚本。详见第九章 Q1。

4.3 MariaDB 安全初始化

若运行脚本时未传 MariaDB root 密码参数,第 10 步会进入交互式向导,逐项回车确认即可(全部选 Y):

Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

实测回显(节选):

OK, successfully used password, moving on...
 ... Success!
Remove anonymous users? [Y/n]  ... Success!
Disallow root login remotely? [Y/n]  ... Success!
 - Dropping test database...
 ... Success!
Thanks for using MariaDB!

若运行脚本时已传入密码参数(本文方式),该向导自动完成,无需交互。

4.4 安装结果验证

脚本第 8 步已内置版本校验(见 4.2 节输出)。完成后重启一次服务器(官方建议),然后逐项复核服务状态:

systemctl is-active apache2
systemctl is-active mariadb
systemctl is-active redis-server
systemctl is-active supervisor

实测回显:

active
active
active
active
php -v | head -1
composer --version
mysql --version
redis-server --version | head -1
apache2 -v | head -1
supervisord --version

实测回显:

PHP 8.4.27 (cli) (built: Oct 21 2026 14:34:07) (NTS)
Composer version 2.10.3 2026-08-27 13:34:23
mysql from 11.2.6-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using  EditLine wrapper
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=d6ed09173b889769
Server version: Apache/2.4.52 (Ubuntu)
4.2.1

基础环境就绪,继续第六章部署 rConfig 主程序。

五、方案 B:手动逐组件安装基础环境

5.1 方案说明

当服务器无法直接运行官方脚本(例如需要审计每条命令、脚本源被网络策略拦截、或需要在既有 MariaDB 上复用版本)时,可按本节手动安装与方案 A 完全等价的基础环境。组件清单与版本要求与官方脚本一致:PHP 8.4 全套扩展、Apache 2.4、MariaDB 11.2、Redis、Supervisor、cron、Composer 2。

5.2 安装 PHP 8.4 与扩展

Ubuntu 22.04 官方源自带 PHP 8.1,不满足 rConfig V8 要求(需 8.2.35/8.3.36/8.4.27+),须添加 ondrej/php 源安装 8.4:

apt -y update
apt -y install software-properties-common
add-apt-repository ppa:ondrej/php -y
apt -y update
apt -y install php8.4 php8.4-cli php8.4-gd php8.4-curl php8.4-mysql php8.4-ldap php8.4-zip php8.4-mbstring php8.4-common php8.4-gmp libapache2-mod-php8.4 php8.4-xml php8.4-snmp

扩展清单与官方脚本完全一致(gd/curl/mysql/ldap/zip/mbstring/common/gmp/xml/snmp + CLI 与 Apache 模块)。验证:

php -v | head -1

实测回显:

PHP 8.4.27 (cli) (built: Oct 21 2026 14:34:07) (NTS)

5.3 安装 Apache、MariaDB 11.2、Redis 与 Supervisor

# Apache
apt -y install apache2
systemctl enable apache2.service

# MariaDB 11.2:使用官方仓库脚本
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version=11.2
apt -y update
apt -y install mariadb-server mariadb-client
systemctl enable mariadb

# Redis 与 Supervisor、cron
apt -y install redis-server supervisor cron
systemctl enable redis-server.service
systemctl enable supervisor

安装 MariaDB 后执行安全初始化:

mariadb-secure-installation

交互应答与 4.3 节一致(unix_socket 认证 Y、设置 root 密码、删匿名用户 Y、禁远程 root Y、删 test 库 Y、刷新权限 Y)。

⚠️ 注意:mariadb_repo_setup 与 dl.rconfig.com、getcomposer.org 同属国外源,若直连超时可改用会话级代理环境变量(export http_proxy=http://192.168.1.62:7897 https_proxy=http://192.168.1.62:7897)后重试,本文实测该代理可用。

5.4 安装 Composer

curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

实测回显:

Composer (version 2.10.3) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

5.5 验证

与方案 A 的 4.4 节验证命令与回显完全一致(php/composer/mysql/redis/apache2/supervisord 六条版本命令 + 四个服务 is-active),此处不再重复。方案 B 完成后同样进入第六章。

六、部署 rConfig 主程序(两方案共用)

本章是 rConfig 本体的七步部署流程,方案 A 与方案 B 完成基础环境后均从本章开始,顺序为:建库 → 克隆与依赖 → Apache 虚拟主机 → Supervisor 队列 → 安装向导 → 缓存与属主收尾 → 首次登录。

6.1 创建数据库与账号

以 root 身份进入 MariaDB,创建专用库与专用账号(本文演示口令 q1w2e3r4,生产环境请换成自己的强口令并妥善保管,第 3 步配置 .env 时还要用到):

mysql -u root -p
CREATE DATABASE rconfig;
CREATE USER 'rconfig_user'@'localhost' IDENTIFIED BY 'q1w2e3r4';
GRANT ALL PRIVILEGES ON rconfig.* TO 'rconfig_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

验证专用账号可连库:

mysql -u rconfig_user -pq1w2e3r4 rconfig -e "SHOW TABLES;"

实测回显(此时库为空,仅表头):

Tables_in_rconfig

迁移完成后同一命令会列出全部数据表(实测 44 张,节选):

Tables_in_rconfig
activity_log
activity_log_archives
categories
category_command
category_device
category_task
commands

6.2 克隆仓库并安装依赖

进入 Web 目录克隆 rConfig 仓库(官方源直连超时的环境按 ⚠️ 走代理):

cd /var/www/html
git clone https://github.com/rconfig/rconfig.git
cd rconfig

⚠️ 下载渠道说明:本文实测 GitHub 直连克隆超时,走代理成功:

git -c http.proxy=http://192.168.1.62:7897 clone https://github.com/rconfig/rconfig.git

克隆完成后可取消仓库级代理配置(git config --unset http.proxy,该参数仅作用于本次克隆命令时无需清理)。

生成环境配置文件并修改关键项:

cp .env.example .env

需要修改的关键项(本文实测值,数据库口令与 6.1 节一致):

APP_URL="http://rconfig-lab"
APP_DIR_PATH=/var/www/html/rconfig
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=rconfig
DB_USERNAME=rconfig_user
DB_PASSWORD=q1w2e3r4

逐项说明:

  • APP_URL:访问 rConfig 使用的 URL,填服务器主机名或 IP(本文以 rconfig-lab 主机名为例,请替换为你的实际值);
  • APP_DIR_PATH:应用绝对路径,默认 /var/www/html/rconfig,与克隆位置保持一致;
  • DB_HOST/DB_PORT/DB_DATABASE:数据库主机、端口与库名,按 6.1 节创建的 rconfig 填写;
  • DB_USERNAME/DB_PASSWORD:6.1 节创建的专用账号与口令。

以 root 身份安装 PHP 依赖(约 2~5 分钟,依赖包较多):

export COMPOSER_ALLOW_SUPERUSER=1
composer self-update --2
yes | composer install --no-dev

⚠️ 注意:COMPOSER_ALLOW_SUPERUSER=1 必须导出,否则 Composer 拒绝以 root 运行,依赖安装会中途失败(官方 Common gotchas 明确提示)。

实测输出(输出节选,实测首尾):

  nesbot/carbon .......................................... DONE
  nunomaduro/termwind .................................... DONE
  opcodesio/log-viewer ................................... DONE
  socialiteproviders/manager ............................. DONE
  spatie/laravel-activitylog ............................. DONE
  spatie/laravel-health .................................. DONE
  spatie/laravel-ignition ................................ DONE
  spatie/laravel-query-builder ........................... DONE

> @php -r "file_exists('vendor/barryvdh/laravel-ide-helper') && passthru('php artisan ide-helper:generate --ansi');"
84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

依赖安装落盘到 /var/www/html/rconfig/vendor(实测 91M)。

6.3 配置 Apache 虚拟主机

官方在仓库根目录提供 setup_apache.sh,一键生成虚拟主机配置:

chmod +x setup_apache.sh
./setup_apache.sh

脚本在 Ubuntu 上生成 /etc/apache2/sites-enabled/rconfig-vhost.conf(RHEL 系为 /etc/httpd/conf.d/rconfig-vhost.conf)。实测生成内容:

<VirtualHost *:80>
        ServerName rconfig-lab
        ServerAlias rconfig-lab
        DocumentRoot /var/www/html/rconfig/public
        <Directory "/var/www/html/rconfig/public">
                Options Indexes FollowSymLinks MultiViews
                Order allow,deny
                Allow from all
                AllowOverride All
                Require all granted
                Satisfy Any
        </Directory>
</VirtualHost>

把其中 ServerName/ServerAlias 改为你的服务器主机名(或删除这两行改用 IP 访问),与 .env 的 APP_URL 保持一致,然后启用 rewrite 模块并重启 Apache:

a2enmod rewrite
systemctl restart apache2

验证虚拟主机已加载:

apache2ctl -S | head -2

实测回显:

VirtualHost configuration:
*:80                   rconfig-lab (/etc/apache2/sites-enabled/rconfig-vhost.conf:1)

6.4 配置 Supervisor 队列进程

rConfig 的配置备份任务走 Laravel Horizon 队列,由 Supervisor 托管。官方提供 setup_supervisor.sh 一键生成配置:

chmod +x setup_supervisor.sh
./setup_supervisor.sh

脚本将配置写入 /etc/supervisor/conf.d/rconfig-core-horizon.conf(RHEL 系为 /etc/supervisord.d/rconfig-core-horizon.ini),核心内容实测如下:

[program:rconfig-core-horizon]
process_name=%(program_name)s
command=/bin/sh -c 'exec php /var/www/html/rconfig/artisan horizon >> /var/www/html/rconfig/storage/logs/horizon.log 2>&1'
autostart=true
autorestart=true
user=www-data
stdout_logfile=/dev/null
stdout_logfile_maxbytes=0
stderr_logfile=/dev/null
stderr_logfile_maxbytes=0
stopwaitsecs=3600

逐项说明:

  • user=www-data:Horizon 以 Web 服务用户身份运行,绝不能是 root(官方安全设计,向导最后一步会校验);
  • command:启动 artisan horizon 并把输出重定向到 storage/logs/horizon.log,该日志由 logrotate 配置 /etc/logrotate.d/rconfig-core-horizon 轮转(超过 50M 切割、保留 10 份、压缩);
  • autostart/autorestart:随 Supervisor 启动、异常退出自动拉起;
  • stopwaitsecs=3600:停止等待上限 1 小时,保证长任务(批量配置下载)不被强杀。

同时脚本会安装 logrotate 配置,实测内容:

/var/www/html/rconfig/storage/logs/horizon.log {
    su www-data www-data
    size 50M
    rotate 10
    compress
    missingok
    notifempty
    copytruncate
}

确认 Supervisor 服务运行并加载了该程序:

systemctl is-active supervisor
supervisorctl status rconfig-core-horizon

实测回显:

active
rconfig-core-horizon             RUNNING   pid 21675, uptime 0:17:30

💡 说明:升级 rConfig 后无需重跑 setup_supervisor.sh——仓库自带的 ./update.sh 会重写该配置(官方文档明确说明)。

6.5 运行安装向导

在应用目录执行官方安装向导,自动完成包发现、应用密钥生成、数据库迁移、数据填充、缓存清理、计划任务同步与 Redis 加固:

cd /var/www/html/rconfig
php artisan v8core:install

实测输出(输出节选,实测首尾):

║                Network Configuration Management System                           ║
║                   rConfig V8 Core • Open Source                                  ║

  Discovering packages ..................
  Generating application key .............
  Running database migrations ............
  Clearing application cache .............
  Synchronizing scheduled tasks ..........
  Optimizing application .................
  Securing Redis .........................

✓ rConfig v8 Core installed successfully!

 Install the scheduler cron file (/etc/cron.d/rconfig-core)? (yes/no) [yes]
 > yes

要点逐项说明:

  • Running database migrations:在 6.1 节创建的 rconfig 库中建表(完成后实测 44 张表,见 6.1 节回显);
  • Securing Redis:向导会为 Redis 生成访问密码并写入 .env(新版安全特性,8.2.x 引入),保证队列未授权访问不可用;这一步失败不会中断安装(提示手动执行 php artisan rconfig:redis-secure 补做);
  • cron 确认项:务必回答 yes。向导以 root 运行时会把计划任务文件写入 /etc/cron.d/rconfig-core,以每分钟一次的频率、以 www-data 用户执行 Laravel 调度器(自动备份、系统维护任务全靠它)。若向导不是以 root 运行,无法写该文件,会改为打印命令提示你手动执行 sudo ./setup_cron.sh。

⚠️ 排障实录:向导完成后访问 Web 出现 HTTP 500、Horizon 日志持续报 Redis NOAUTH 错误。原因是向导的 Optimizing application 步骤(在 Securing Redis 之前执行)把当时还没有 Redis 密码的配置缓存到了 bootstrap/cache/config.php,随后 Securing Redis 写入 .env 的密码对已缓存配置不生效,应用仍用无密码配置连接已加密码的 Redis。解决(实测有效):

rm -f /var/www/html/rconfig/bootstrap/cache/config.php
cd /var/www/html/rconfig && php artisan rconfig:clear-all
supervisorctl restart rconfig-core-horizon

处理后 Web 恢复正常(/login 返回 200),Horizon 回到 RUNNING。

cron 文件确认(回答 yes 后应存在):

cat /etc/cron.d/rconfig-core

实测回显:

# rConfig V8 Core scheduler. Written by setup_cron.sh, do not edit: it is
# rewritten on every install and upgrade. Runs as the web user, never root.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * www-data cd /var/www/html/rconfig && php artisan schedule:run >> /dev/null 2>&1

6.6 清理缓存与目录属主

最后清一遍应用缓存并把可写目录属主交给 Web 服务用户。顺序必须是先清缓存、后 chown——root 身份清缓存会重建出 root 属主的缓存文件,先 chown 再清缓存会把 root 属主文件留在可写目录里(官方 Common gotchas 明确提示):

cd /var/www/html/rconfig
php artisan rconfig:clear-all
chown -R www-data:www-data storage bootstrap/cache

6.7 首次登录与账号安全

浏览器访问 http://<服务器IP或主机名>,未登录会被重定向到登录页。实测(未带会话 curl):

curl -I http://127.0.0.1/

实测回显:

HTTP/1.1 302 Found
Server: Apache/2.4.52 (Ubuntu)
Location: http://127.0.0.1/login

登录页本身返回 200:

curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1/login

实测回显:

200

使用官方默认账号首次登录:邮箱 admin@domain.com,密码 admin。

⚠️ 注意:默认账号是公开已知的,登录后必须立即改密。本文后续示例统一使用演示账号:邮箱 admin@rconfig.local、用户名 admin、密码 q1w2e3r4(在 Settings → Users 中把默认账号的邮箱与密码改为该值,或新建同权限账号后停用默认账号)。

改密后用 curl 验证登录接口可用(rConfig 登录页为前后端分离形态,需先取 CSRF cookie 再提交):

cd /tmp
rm -f c.txt
curl -s -c c.txt http://127.0.0.1/sanctum/csrf-cookie -o /dev/null
TOKEN=$(grep XSRF-TOKEN c.txt | awk '{print $7}' | python3 -c "import sys,urllib.parse;print(urllib.parse.unquote(sys.stdin.read().strip()))")
curl -s -b c.txt -c c.txt -w "\nHTTP_STATUS:%{http_code}\n" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -H "X-XSRF-TOKEN: $TOKEN" -H "Referer: http://127.0.0.1/login" \
  -d '{"username":"admin@rconfig.local","password":"q1w2e3r4"}' \
  http://127.0.0.1/login

实测回显:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url='http://127.0.0.1/dashboard'" />

        <title>Redirecting to http://127.0.0.1/dashboard</title>
    </head>
    <body>
        Redirecting to <a href="http://127.0.0.1/dashboard">http://127.0.0.1/dashboard</a>.
    </body>
</html>
HTTP_STATUS:302

登录成功后带会话访问仪表盘返回 200:

curl -s -b /tmp/c.txt -o /dev/null -w "%{http_code}\n" http://127.0.0.1/dashboard

实测回显:

200

⚠️ 实测发现:登录接口的 username 字段必须传邮箱格式的值。若传入非邮箱字符串(如 admin),后端会改按 username 字段查库(数据表无此列),返回 These credentials do not match our records.。用邮箱(如 admin@rconfig.local)即可正常登录。

6.8 安装验证清单

逐项确认(全部来自实测):

检查项验证命令实测结果
Web 可访问curl -sI http://127.0.0.1/302 → /login
登录可用6.7 节 curl 登录302 → /dashboard
Apache 运行systemctl is-active apache2active
MariaDB 运行systemctl is-active mariadbactive
Redis 运行systemctl is-active redis-serveractive
Supervisor 运行systemctl is-active supervisoractive
Horizon 队列supervisorctl status rconfig-core-horizonRUNNING
计划任务cat /etc/cron.d/rconfig-core文件存在,www-data 每分钟调度
数据表就绪mysql -u rconfig_user -pq1w2e3r4 rconfig -e "SHOW TABLES;"44 张表
无 root 运行的队列向导末步自动执行 php artisan rconfig:check-worker-user无 FAIL 行即通过

另有两项收尾动作建议完成(与官方文档一致):

# 更新厂商设备模板库(从 GitHub 拉取最新模板,网络受限时同样可走代理)
cd /var/www/html/rconfig
php artisan rconfig:clone-templates

# 配置自签名 HTTPS(8.2.19 起仪表盘在无 HTTPS 时会显示安全提示)
# 该命令需要以 root 执行并修改 Apache 配置,请在确认后再运行
sudo php artisan rconfig:ssl-self-signed

rconfig:ssl-self-signed 会添加 HTTPS 虚拟主机、把 HTTP 重定向到 HTTPS 并更新 APP_URL;自签名证书浏览器会告警,生产环境建议改用 Let's Encrypt 或企业 PKI 证书。设备添加与连通性测试的完整流程见后续《rConfig 8.2.19 常用 CLI 与运维命令详解》篇。

七、方案对比与选择建议

维度方案 A:官方脚本自动安装方案 B:手动逐组件安装
覆盖范围基础环境 11 步一键完成逐组件手动安装,等价覆盖
耗时(实测/估算)约 10~20 分钟(含系统包下载)约 30~40 分钟
版本一致性官方锁定(PHP 8.4 + MariaDB 11.2 + Redis/Supervisor)需自行保证版本匹配(尤其 PHP ≥8.2.35 与 MariaDB 11.2)
可审计性脚本体量大,逐行审计成本高每条命令透明可控
适用场景全新服务器、快速上线(推荐)定制环境、脚本源不可达、需复用既有数据库
主程序部署第六章流程第六章流程(相同)

选择建议:全新服务器无脑选方案 A;方案 B 用于需要命令级审计或官方脚本不可用的场景。两方案产出的基础环境一致,rConfig 主程序部署流程完全相同。

八、配置说明

rConfig 的运行配置集中在 Laravel 标准的 .env 文件(/var/www/html/rconfig/.env),修改后需重启 Horizon 并清缓存生效:

cd /var/www/html/rconfig
php artisan rconfig:clear-all
supervisorctl restart rconfig-core-horizon

安装直接相关的核心键(实测值):

键实测值说明
APP_ENVproduction运行环境,生产保持 production
APP_URLhttp://rconfig-lab对外访问 URL,与 Apache ServerName 一致
APP_DIR_PATH/var/www/html/rconfig应用绝对路径
DB_HOST / DB_PORTlocalhost / 3306数据库地址与端口
DB_DATABASErconfig库名
DB_USERNAME / DB_PASSWORDrconfig_user / q1w2e3r4专用库账号
QUEUE_CONNECTIONredis队列后端固定为 redis,Horizon 依赖它
REDIS_HOST / REDIS_PORTlocalhost / 6379Redis 地址与端口

⚠️ 注意:向导的 Securing Redis 步骤会在 .env 中写入 Redis 访问密码(键名为 REDIS_PASSWORD),该值同时会设置到 Redis 服务端,请勿手工删除,否则队列将连不上 Redis(NOAUTH)。

其他 .env 配置项(邮件、会话、日志级别、设备并发下载等)数量较多,逐项含义与取值建议见《rConfig 8.2.19 配置参数详解》篇。

关键目录速查:

路径用途
/var/www/html/rconfig/.env全部运行配置
/var/www/html/rconfig/storage/logs/应用日志(laravel-YYYY-MM-DD.log)与 horizon.log
/var/www/html/rconfig/storage/app/rconfig/data/下载的设备配置文件落盘目录
/etc/apache2/sites-enabled/rconfig-vhost.confApache 虚拟主机
/etc/supervisor/conf.d/rconfig-core-horizon.confHorizon 队列进程配置
/etc/cron.d/rconfig-core计划任务(每分钟调度)
/etc/logrotate.d/rconfig-core-horizonHorizon 日志轮转(50M × 10 份压缩)

九、常见问题(FAQ)

Q1:运行官方脚本报 sudo: command not found,第 3 步失败退出。 精简系统未预装 sudo(脚本所有命令都经 sudo 执行)。实测错误:

./install.sh: line 151: sudo: command not found
[!]  Failed to install cron with apt-get. Trying with apt.
./install.sh: line 167: sudo: command not found
[✗]  Failed to install cron with snap. Exiting.

解决:apt-get update && apt-get install -y sudo 后重新运行脚本,11 步可全部通过(实测验证)。

Q2:composer install 中途失败,提示不允许 root 运行。 Composer 默认禁止 root 执行。先 export COMPOSER_ALLOW_SUPERUSER=1 再运行 yes | composer install --no-dev(官方 Common gotchas 明确要求,见 6.2 节)。

Q3:Apache 返回 404 或 500,页面无法访问。 两个常见原因:一是改错了虚拟主机路径——Ubuntu 上文件在 /etc/apache2/sites-enabled/rconfig-vhost.conf(RHEL 系才是 /etc/httpd/conf.d/),请用 apache2ctl -S 确认加载的是正确文件(实测回显见 6.3 节);二是漏开 rewrite 模块,执行 a2enmod rewrite && systemctl restart apache2。

Q4:向导完成后 Web 打开 500,Horizon 日志报 NOAUTH。 Redis 密码写入 .env 后旧配置缓存未失效(详见 6.5 节排障实录)。执行 rm -f bootstrap/cache/config.php && php artisan rconfig:clear-all && supervisorctl restart rconfig-core-horizon。

Q5:空白页或 500,且日志报权限错误。 按「先清缓存、后 chown」的顺序执行(顺序反了会留下 root 属主缓存文件):

cd /var/www/html/rconfig
php artisan rconfig:clear-all
chown -R www-data:www-data storage bootstrap/cache

仍异常时看应用日志定位:

tail -f /var/www/html/rconfig/storage/logs/laravel.log

⚠️ 注意:不要对应用目录执行 chmod -R 755 或 chmod -R 775——下载的设备配置文件里含设备凭据,放宽权限会让所有本地用户可读。误操作后执行 php artisan rconfig:set-config-permissions 恢复(官方推荐做法,会把配置文件权限收回为仅 Web 用户可读)。

Q6:队列任务不处理(备份一直排队)。

supervisorctl status rconfig-core-horizon
supervisorctl start rconfig-core-horizon   # 若为 STOPPED/FATAL 则手动拉起
tail -f /var/www/html/rconfig/storage/logs/horizon.log
tail -f /var/log/supervisor/supervisord.log

若程序定义缺失或运行用户不对,重跑 sudo ./update.sh --no-pull(不拉新代码、只重建配置与属主)。

Q7:登录报 These credentials do not match our records.,但密码确认无误。 登录接口的 username 字段必须传邮箱格式(如 admin@rconfig.local);传非邮箱字符串会改按 username 列查询(表中不存在),必然失败。见 6.7 节实测说明。

Q8:向导没写 /etc/cron.d/rconfig-core,定时备份不跑。 向导非 root 运行时无法写该文件,会打印命令提示。手动补写:在应用目录执行 sudo ./setup_cron.sh,然后 cat /etc/cron.d/rconfig-core 确认内容与 6.5 节回显一致。

Q9:数据库连接报错。 先用专用账号直连验证:mysql -u rconfig_user -pq1w2e3r4 rconfig -e "SHOW TABLES;"。能连说明数据库正常,再核对 .env 中 DB_USERNAME/DB_PASSWORD/DB_DATABASE 三项与 6.1 节创建的值是否一致。

十、卸载与清理

⚠️ 以下操作会永久删除 rConfig 及其全部配置备份数据,执行前务必确认已另行备份(设备配置文件在 /var/www/html/rconfig/storage/app/rconfig/data/,数据库用 mysqldump -u rconfig_user -p rconfig > rconfig-backup.sql 导出)。

# 1. 停止队列并移除托管配置
supervisorctl stop rconfig-core-horizon
rm -f /etc/supervisor/conf.d/rconfig-core-horizon.conf
supervisorctl reread
supervisorctl update

# 2. 移除计划任务与日志轮转配置
rm -f /etc/cron.d/rconfig-core
rm -f /etc/logrotate.d/rconfig-core-horizon

# 3. 移除 Apache 虚拟主机并重启
a2dissite rconfig-vhost.conf 2>/dev/null || rm -f /etc/apache2/sites-enabled/rconfig-vhost.conf
systemctl reload apache2

# 4. 删除应用目录
rm -rf /var/www/html/rconfig

# 5. 删除数据库与专用账号(进入 mysql 后执行)
#    DROP DATABASE rconfig;
#    DROP USER 'rconfig_user'@'localhost';
#    FLUSH PRIVILEGES;

验证清理结果:

supervisorctl status rconfig-core-horizon   # 应报 no such process
ls /etc/cron.d/rconfig-core                 # 应报 No such file or directory
mysql -u rconfig_user -p -e "SHOW DATABASES;" 2>/dev/null   # 账号已删则连接失败

基础组件(PHP/Apache/MariaDB/Redis/Supervisor)如服务器还承载其他业务则保留;确认无他用时可按标准 apt 方式卸载(apt purge apache2 mariadb-server redis-server supervisor 及 php8.4-* 包),此处不展开。

十一、参考链接