Centos7下部署librenms

1.参考官方文档部署完成

Installing LibreNMS - LibreNMS Docs

 2.关闭selinux,配置yum源

setenforce 0

sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

 2.配置PHP源,安装所需组件

yum install -y yum-utils

yum localinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager --enable remi-php73

yum install composer cronie fping git ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-gd php-mbstring php-process php-snmp php-xml php-zip php-memcached php-mysqlnd python-memcached rrdtool python3 python3-pip python3-devel

 3.git下载librenms最新版本

cd /opt

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

4.创建用户

 useradd librenms -d /opt/librenms -M -r

usermod -a -G librenms nginx

chown -R librenms:librenms /opt/librenms

chmod 770 /opt/librenms

chgrp apache /var/lib/php/session/

4.切换用户配置PHP环境

su - librenms

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

exit

 

5.配置数据库

systemctl start mariadb

mysqladmin -u root password 'MySQL@2022'

mysql -u root -pMySQL@2022 登录数据库并创建如下数据库表

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'librenms@2021'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; FLUSH PRIVILEGES;

exit

 vi /etc/my.cnf

[mysqld]下加入如下两行

datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock

systemctl enable --now mariadb

6.配置PHP环境

vi /etc/php.ini

修改时区配置如下 date.timezone = Asia/Shanghai

 vi /etc/php-fpm.d/www.conf 修改成如下行

;user = apache

user = nginx

group = apache

;keep group as apache

;listen = 127.0.0.1:9000

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

listen.owner = nginx

listen.group = nginx

listen.mode = 0660

systemctl enable --now php-fpm

 7.配置nginx

vi /etc/nginx/conf.d/librenms.conf

server {

listen 80;

server_name librenms.test.com;

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:/run/php-fpm/php-fpm.sock; }

location ~ /\.ht {

deny all; } }

并删掉/etc/nginx/nginx.conf中server段默认配置 systemctl enable--now nginx

 

8.snmpd配置

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

vi /etc/snmp/snmpd.conf中团体名,例如librenms com2sec readonly default librenms

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

chmod +x /usr/bin/distro

systemctl enable --now snmpd

9.crond与logrotate配置

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

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

10.登陆web界面

设置中文界面

添加设备

 

页面展示

 

 

 

 

 

 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值