2022年9月27日 星期二

Ubuntu 20.04 LibreNMS update PHP 7 to 8

先更新
sudo apt update
sudo apt upgrade


環境PHP

先依照
https://docs.librenms.org/Installation/Install-LibreNMS/#manual-update


安裝PHP套件與升級


apt install software-properties-common
add-apt-repository universe
add-apt-repository ppa:ondrej/php
apt update
apt install acl curl apache2 fping git graphviz imagemagick libapache2-mod-fcgid mariadb-client mariadb-server mtr-tiny 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 whois python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip
安裝 PHP dependencies

su - librenms
./scripts/composer_wrapper.php install --no-dev
exit
設定Set timezone 
PHP 時區參考
https://www.php.net/manual/en/timezones.asia.php

Asia/Taipei
vi /etc/php/8.1/fpm/php.ini
vi /etc/php/8.1/cli/php.ini
設定OS系統時間一致

timedatectl set-timezone Asia/Taipei


跳過Mysql

設定 PHP-FPM


cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/librenms.conf
vi /etc/php/8.1/fpm/pool.d/librenms.conf

Change [www] to [librenms]:

[librenms]

Change user and group to "librenms":

user = librenms
group = librenms

Change listen to a unique name:

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

接下來跳過到

Cron job

cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

這裡會有個錯誤須進入修改,與畫面一致(去cd )

vi /etc/cron.d/librenms




之後停用php7.x-fpm

systemctl disable php7.4-fpm.service

啟用php8套件

a2dissite 000-default a2enmod proxy_fcgi setenvif rewrite a2ensite librenms.conf systemctl restart apache2 systemctl restart php8.1-fpm



檢測與更新

sudo su - librenms ./validate.php
./daily.sh


如果遇到以下錯誤,查看log為cronjob錯誤,如前圖修正:


No active polling method detected


vi /etc/cron.d/librenms




參考文獻
https://docs.librenms.org/Installation/Install-LibreNMS/#manual-update
https://community.librenms.org/t/issue-with-new-instalation/19332/6