Setup LibreNMS On Ubuntu 16.04 | 18.04 | 18.10 |
1. Install Nginx
first we need nginx for the web
server. Install nginx using the command below.
#sudo apt update
#sudo apt install nginx
After installation is complete, use the
following command to start, check status, and also enable nginx service status
#sudo systemctl start nginx.service
#sudo systemctl status nginx.service
#sudo systemctl enable nginx.service
to ensure a successful installation, we
can access the ip / domain through a browser
2. Install MriaDB
to install mariadb, follow the
command below
#sudo apt-get install mariadb-server mariadb-client
After installation is complete, use the
command below to start, check the status and also enable the MySQL status
run
these on ubuntu 16.04
#sudo systemctl stop mysql.service
#sudo systemctl start mysql.service
#sudo systemctl enable mysql.service
run
these on ubuntu 18.04
#sudo systemctl stop mariadb.service
#sudo systemctl start mariadb.service
#sudo systemctl enable mariadb.service
After that, run the commands below to
secure MariaDB server by creating a root password and disallowing remote root
access.
#sudo mysql_secure_installation
When prompted, answer the questions
below by following the guide.
Enter current password for root (enter for none): Just
press the Enter
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
To test if MariaDB is installed, type the commands below
to logon to MariaDB server
When finished, we can access mysql by
using the command below
#sudo mysql -u root -p
3. Install PHP 7.2 and Related Modules
add php7.2 repository, then install
php7.2 by doing the command below
#sudo apt-get install software-properties-common
#sudo add-apt-repository ppa:ondrej/php
#sudo apt update
#sudo apt install php7.2-fpm php7.2-common php7.2-mysql
php7.2-gmp php7.2-curl php7.2-snmp php7.2-json php7.2-intl php7.2-mbstring
php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
after that edit the php.ini file and
adjust the parameters within it.
#sudo nano /etc/php/7.2/fpm/php.ini
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = Asia/Makassar
when finished, restart nginx service
#sudo systemctl restart nginx.service
4. Create LibreNMS Database
now, after everything needed to
run LibreNMS has all been installed, we now configure the server. First create
a database that will be used by LibreNMS
#sudo mysql -u root –p
create a database with the name librenms
CREATE DATABASE librenms;
Create librenms database users and
passwords
CREATE USER 'librenmsuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the
database
GRANT ALL ON librenms.* TO 'librenmsuser'@'localhost' IDENTIFIED BY 'user_password_here'
WITH GRANT OPTION;
Save and exit
FLUSH PRIVILEGES;
EXIT;
Add the parameters below in the mysql
configuration
#sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
innodb_file_per_table=1
lower_case_table_names=0
Install these additional dependencies to
satisfy LibreNMS installation
#sudo apt install curl git composer fping graphviz
imagemagick nmap python-memcache python-mysqldb rrdtool snmp snmpd whois
#curl -sS https://getcomposer.org/installer | sudo php --
--install-dir=/usr/local/bin --filename=composer
5. Install LibreNMS
the next step is to add the user
for librenms and also add the user to the default www-data (nginx) group
#sudo useradd librenms -d /opt/librenms -M -r
#sudo usermod -a -G librenms www-data
move to the opt directory and
download librenms
#cd /opt
#sudo composer create-project --no-dev --keep-vcs librenms/librenms
librenms dev-master
After that, configure SNMP server
#sudo cp /opt/librenms/snmpd.conf.example
/etc/snmp/snmpd.conf
#sudo nano /etc/snmp/snmpd.conf
install the following script to get the
distribution information in librenms
#sudo curl -o /usr/bin/distro
https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
change permission to be executed
#sudo chmod +x /usr/bin/distro
last restart snmpd
#sudo systemctl restart snmpd
run this command to create a cron task
for librenms
#sudo cp /opt/librenms/librenms.nonroot.cron
/etc/cron.d/librenms
LibreNMS keeps logs in
/opt/librenms/logs. Over time these can become large and be rotated out. To
rotate out the old logs you can use the provided logrotate config file:
#sudo cp /opt/librenms/misc/librenms.logrotate
/etc/logrotate.d/librenms
When we’re done, run the commands below
to configure an appropriate permissions for LibreNMS user account
#sudo chown -R librenms:librenms /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/
6. Configure LibreNMS
create a file in / etc / nginx / site-available and add the
parameters below. Then save and exit.
#sudo nano /etc/nginx/sites-available/librenms
server {
listen 80;
listen [::]:80;
root
/opt/librenms/html;
index index.php;
server_name example.com www.example.com;
client_max_body_size 100M;
location / {
try_files
$uri $uri/ /index.php?$query_string;
}
location /api/v0
{
try_files
$uri $uri/ /api_v0.php?$query_string;
}
location ~
\.php$ {
include
snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include
fastcgi_params;
}
}
7. Enable LibreNMS
After configuring the VirtualHost
above, enable it by running the commands below
#sudo ln -s /etc/nginx/sites-available/librenms
/etc/nginx/sites-enabled/
8. Restart Nginx
To load all the settings above,
restart Nginx by running the commands below.
#sudo systemctl restart nginx.service
Finally, run the commands below to
complete the setup
#cd /opt/librenms
#sudo ./scripts/composer_wrapper.php install --no-dev
Next, open your browser and browse to the
URL below to begin the setup
http://example.com/install.php/
You should see LibreNMS setup page. Continue
with the setup wizard until done
stage 0 |
stage 1 |
in stage 1 we need to input DBuser and DB pass that we create before
stage 3 |
Stage 3 input username, password and email that we use to login to LibreNMS
stage 5 |
so i create manually file config.php then copy paste config below
stage 6 |
complete |
device list LibreNMS |