安裝基本上跟教學文差不會太多
首先,裝好ubuntu22.04後,要來安裝所需的軟體包
$ apt-get install net-tools openssh-server
$ apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny apache2 libapache2-mod-php8.1 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 unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip
$ cd /opt
$ git clone https://github.com/librenms/librenms.git
新增一個 user 名為 librenms
$ useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
將 libreNMS 目錄的擁有者設為 librenms
$ 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/
設定librenms帳號密碼
$ passwd librenms
安裝 PHP 依賴項
$ su - librenms
$ cd /opt/librenms
$ ./scripts/composer_wrapper.php install --no-dev
$ exit
systemctl restart mysql
mysql -uroot -p
這時候會在mysql模式下,就輸入下面這些指令,注意! password這邊要改成你要設定的password密碼
mysql>CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
exit
vi /etc/mysql/mariadb.conf.d/50-server.cnf
//隨便找地方新增下面兩行後存檔離開
innodb_file_per_table=1
lower_case_table_names=0
systemctl restart mysql
nano /etc/php/8.1/apache2/php.ini
設定完記得/etc/init.d/apache2 restart
date.timezone = "Asia/Taipei"
timedatectl set-timezone Asia/Taipei
vi /etc/apache2/sites-available/librenms.conf
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
# ServerName librenms.lab.com
AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>
注意:如果這是您在此服務器上託管的唯一站點(應該是:)),那麼您將需要禁用默認站點。
$ a2dissite 000-default
$ a2ensite librenms.conf
$ a2enmod rewrite
$ systemctl restart apache2
#其實到這邊網站應該就可以打得開了,剩下就是一些權限要處理,如果你只是測試教學用的話,你可以輸入下面這樣直接處理掉權限問題. 但是不太安全就是
chmod 777 /opt/librenms/logs/librenms.log
chgrp www-data /opt/* -R
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
LibreNMS 保持登錄/opt/librenms/logs
。隨著時間的推移,這些可能會變大並被輪換出來。要輪換舊日誌,您可以使用提供的 logrotate 配置文件:
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms