- Log into the Debian device
- Run the following commands in a terminal:
# update software repositories
sudo apt update
# install software updates
sudo apt upgrade -y
# install pre-requisites
sudo apt install acl curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nmap rrdtool snmp snmpd whois unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip -y
# install Apache and MySQL
sudo apt install apache2 libapache2-mod-fcgid mariadb-server mariadb-client -y
# install PHP components
sudo 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 -y
# create librenms user
sudo useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
# clone librenms github repo
sudo git clone https://github.com/librenms/librenms.git /opt/librenms
# set permissions
sudo chown -R librenms:librenms /opt/librenms
sudo chmod 771 /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
# install composer dependencies
sudo su - librenms
./scripts/composer_wrapper.php install --no-dev
exit
# set time zone for PHP fpm
sudo nano /etc/php/7.3/fpm/php.ini - Press CTRL+W to search > type timezone > Press Enter
- Remove the ; to uncomment the line
- Type in a valid timezone (https://php.net/manual/en/timezones.php)
- Press CTRL+O, Enter, CTRL+X to write the changes to php.ini
- Continue with the following commands in a terminal:
# set time zone for PHP cli
sudo nano /etc/php/7.3/cli/php.ini - Press CTRL+W to search > type timezone > Press Enter
- Remove the ; to uncomment the line
- Type in a valid timezone (https://php.net/manual/en/timezones.php)
- Press CTRL+O, Enter, CTRL+X to write the changes to php.ini
- Continue with the following commands in a terminal:
-
# set system time zone
sudo timedatectl set-timezone America/New_York
# edit mariaDB configuration
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf - Paste the following under the [mysqld] section
innodb_file_per_table=1
lower_case_table_names=0 - Press CTRL+O, Enter, CTRL+X to write the changes to 50-server.cnf
- Continue with the following commands in a terminal:
# restart mariadb service
sudo systemctl restart mariadb
# configure the MySQL database
sudo su
mysql_secure_installation - Press Enter to login as root
- Type Y and press Enter to set a root password, type the password twice to confirm
- Type Y and press Enter to remove anonymous users
- Type Y and press Enter to disallow root login remotely
- Type Y and press Enter to remove the test database
- Type Y and press Enter to reload privilege tables
- Run the following command to login into MySQL:
mysql -u root -p
- Authenticate with the root password set earlier
- Run the following commands to create the LibreNMS database and database user
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms_rw'@'localhost' IDENTIFIED BY 'Libr3NM$!';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms_rw'@'localhost';
FLUSH PRIVILEGES;
EXIT;
exit - Continue with the following commands:
# make a copy of www.conf
sudo cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf
# edit librenms.conf
sudo nano /etc/php/7.3/fpm/pool.d/librenms.conf - Replace [www] with [librenms]
- Change the user and group to librenms
user = librenms
group = librenms - Change the listen to php-fpm-librenms.sock
listen = /run/php-fpm-librenms.sock
- Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf
- Continue with the following commands:
# create librenms apache conf
sudo nano /etc/apache2/sites-available/librenms.conf - Paste the following configuration into librenms.vhost
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
#ServerName librenms.example.comAllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory># Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule><FilesMatch ".+\.php$">
SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost> - Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf
- Continue with the following commands:
# enable the librenms site and reload apache
sudo a2dissite 000-default
sudo a2enmod proxy_fcgi setenvif rewrite
sudo a2ensite librenms.conf
sudo systemctl restart apache2
sudo systemctl restart php7.3-fpm
# install dispatcher service
sudo su - librenms
pip3 install -r requirements.txt
exit
sudo cp /opt/librenms/misc/librenms.service /etc/systemd/system/librenms.service
sudo systemctl enable --now librenms.service
# enable snmp
sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
sudo nano /etc/snmp/snmpd.conf - Change RANDOMSTRINGGOESHERE to a unique community string to use for SNMP
- Press CTRL+O, Enter, CTRL+X to write the changes to snmpd.conf
- Continue with the following commands:
# download librenms snmp
sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
# set permissions
sudo chmod +x /usr/bin/distro
# restart snmp service
sudo systemctl enable snmpd
sudo systemctl restart snmpd - Open a web browser and navigate to http://DNSorIP//install
- The LibreNMS setup screen should be displayed
- Click the Configure Database icon
- Select MySQL and fill out the database connection information as follows
Host: localhost
Port: 3306
User: librenms_rw
Password: Libr3NM$!
Database Name: librenms - Click the Check Credentials button
- Click the Build Database button
- Once the database has been created successfully, click the Created Admin User icon
- Enter a username, password and email address > Click the Add User button
- Click the Finish Install icon
- Click the validate your install link
- Log in using the admin user credentials created earlier
- Welcome to LibreNMS
Source: https://docs.librenms.org/Installation/Install-LibreNMS/
Check out for day in life on YouTube for more on LibreNMS: https://www.youtube.com/playlist?list=PLxiGkbpIzunT_YOwUEukOB6DpF8N8MXkQ