本文採用 Ubuntu 22.04 為作業系統,引用來源為 https://docs.librenms.org/Installation/Install-LibreNMS/


首先將使用者切換至 root 身份

apt install software-properties-common
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt update
apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php-cli php-curl php-fpm php-gd php-gmp php-json php-mbstring php-mysql php-snmp php-xml php-zip rrdtool snmp snmpd unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-psutil python3-systemd python3-pip whois traceroute vim

新增 librenms 使用者

useradd librenms -d /opt/librenms -M -r -s "$(which bash)"

下載 LibreNMS

cd /opt
git clone https://github.com/librenms/librenms.git

設定權限

chown -R librenms:librenms /opt/librenms
chmod 771 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

安裝 PHP

su - librenms
./scripts/composer_wrapper.php install --no-dev
exit

設定時區

vim /etc/php/8.3/fpm/php.ini
vim /etc/php/8.3/cli/php.ini
timedatectl set-timezone Asia/Taipei

配置 MariaDB

vim /etc/mysql/mariadb.conf.d/50-server.cnf

在[mysqld]部分中新增:

innodb_file_per_table=1
lower_case_table_names=0

重啟MariaDB

systemctl enable mariadb
systemctl restart mariadb

[!WARNING]

注意:將下面的“lxIPNigpSHenrhzk48Nm”更改為安全的密碼。 (為避免懶人複製,預設放一個長度20碼的密碼。)

CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'lxIPNigpSHenrhzk48Nm';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
exit

配置 PHP-FPM

cp /etc/php/8.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/librenms.conf
vim /etc/php/8.3/fpm/pool.d/librenms.conf

將[www]改為[librenms] :

[librenms]

將user和group更改為“librenms”:

user = librenms
group = librenms

變更listen必須與您的網路伺服器設定相符的唯一路徑(NGINX 為fastcgi_pass ,Apache 為SetHandler ):

listen = /run/php-fpm-librenms.sock