網頁

2019年7月28日 星期日

Librenms 安裝

開源網路裝置管理系統 - LibreNMS
相關介紹請參考:
http://blog.jason.tools/2017/06/librenms-networkmanager-good.html

>>以下參考官網文件,然後做一些修正
>>https://docs.librenms.org/Installation/Installation-Ubuntu-1804-Nginx/

>>安裝在debian 10的版本



su -

apt install software-properties-common

apt update
apt install curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap

apt install php7.3-cli php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mbstring php7.3-mysql php7.3-snmp php7.3-xml php7.3-zip

apt install python-memcache python-mysqldb rrdtool snmp snmpd whois acl


>>增加使用者
useradd librenms -d /opt/librenms -M -r -p 1234

--------------這一段為說明---開始----
>>若要改變預設的家目錄,可以加上 -d 參數並指定家目錄的路徑:
>>指定家目錄
>>sudo useradd -d /data/libre_abc libre_abc

>>加上 -M 參數:
>>不建立家目錄

>>sudo useradd -M libre_abc

>>-r 指新增系統帳號 -p 指密碼

>>要將新的使用者加入既有的群組中,可以加上 -g 參數,並指定群組的名稱或群組 ID:

>> 指定主要群組

>>sudo useradd -g www-data libre_abc

>>這樣就會將 libre_abc 這個新使用者的主要群組設定為 www-data(www-data 這個群組必須事先建立好)。
>>除了主要的群組之外,每一位使用者也可以同時隸屬於其他多個不同的群組,如果要在新增使用者時,一起加入其群組內,可以加上 -G 參數,並以逗號分隔的方式指定每一個要加入的群組:

>>加入其他群組

>>sudo useradd -g www-data -G admin,developer,leader libre_abc

>>這樣新增的 libre_abc 帳號的主要群組是 www-data,同時也是 admin、developer、leader 三個群組的成員。
---這一段為說明---結束----

usermod -a -G librenms www-data

 cd /opt

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

chown -R librenms:librenms /opt/librenms

chmod 770 /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/

su - librenms

./scripts/composer_wrapper.php install --no-dev

exit

systemctl restart mysql

mysql -u root -p

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

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

Within the [mysqld] section please add:

innodb_file_per_table=1
lower_case_table_names=0


---在以下2個ini檔加入Timezone---

nano /etc/php/7.3/fpm/php.ini
nano /etc/php/7.3/cli/php.ini

date.timezone = Asia/Taipei

---加入Timezone---
systemctl restart php7.3-fpm

nano /etc/nginx/conf.d/librenms.conf
>>(新增檔案及以下內容)

server {
 listen      80;
 server_name ip;
#先用ip,上線後用完整名稱
 root        /opt/librenms/html;
 index       index.php;

 charset utf-8;
 gzip on;
 gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
 location / {
  try_files $uri $uri/ /index.php?$query_string;
 }
 location /api/v0 {
  try_files $uri $uri/ /api_v0.php?$query_string;
 }
 location ~ \.php {
  include fastcgi.conf;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
#請注意上一行的php7.3-fpm版本位置及名稱
 }
 location ~ /\.ht {
  deny all;
 }
}
>>檔案結束------------------------------------------------------------

rm /etc/nginx/sites-enabled/default

systemctl restart nginx

>>這是指這一機器如果要被監控,所要用的 snmp  community string.

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf

nano /etc/snmp/snmpd.conf

Edit the text which says {RANDOMSTRINGGOESHERE} and set your own community string.{public}

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro

chmod +x /usr/bin/distro

systemctl restart snmpd


-----被監控的段落結束-----

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

chown -R librenms:librenms /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/

>>這樣就準備好要進入網頁安裝了。
>>不小心截圖沒存到,還好只有6個畫面,大家應該都可以完成吧!

沒有留言:

張貼留言