2021-07-09 05:10:05 +08:00
# Install LibreNMS
## Prepare Linux Server
2020-06-27 11:13:32 -05:00
You should have an installed Linux server running one of the supported OS.
2020-06-29 16:17:07 -05:00
Make sure you select your server's OS in the tabbed options below.
2020-06-27 11:13:32 -05:00
Choice of web server is your preference, NGINX is recommended.
Connect to the server command line and follow the instructions below.
2022-08-05 00:58:03 +02:00
!!! note
2020-05-31 21:45:39 -05:00
2022-08-05 00:58:03 +02:00
These instructions assume you are the **root ** user.
If you are not, prepend `sudo` to the shell commands (the ones that aren't
at `mysql>` prompts) or temporarily become a user with root
privileges with `sudo -s` or `sudo -i` .
2020-05-31 21:45:39 -05:00
2020-10-24 11:19:45 +02:00
**Please note the minimum supported PHP version is @= php.version_min =@**
2020-05-31 21:45:39 -05:00
2020-10-09 14:52:02 +02:00
## Install Required Packages
2020-05-31 21:45:39 -05:00
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
=== "NGINX"
```
2024-09-04 09:55:39 -05:00
apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full 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 unzip python3-command-runner python3-pymysql python3-dotenv python3-redis python3-setuptools python3-psutil python3-systemd python3-pip whois traceroute
2024-08-30 16:41:27 +03:30
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
=== "NGINX"
2022-08-05 00:58:03 +02:00
```
2024-09-04 09:55:39 -05:00
apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full 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 unzip python3-command-runner python3-pymysql python3-dotenv python3-redis python3-setuptools python3-psutil python3-systemd python3-pip whois traceroute
2022-08-05 00:58:03 +02:00
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
=== "NGINX"
2020-05-31 21:45:39 -05:00
```
apt install software-properties-common
add-apt-repository universe
2022-08-05 00:58:03 +02:00
add-apt-repository ppa:ondrej/php
2020-05-31 21:45:39 -05:00
apt update
2023-12-15 11:06:03 -05:00
apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full 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 unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip whois traceroute
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
2024-05-07 23:26:45 -05:00
=== "Apache"
2020-05-31 21:45:39 -05:00
```
apt install software-properties-common
add-apt-repository universe
2022-08-05 00:58:03 +02:00
add-apt-repository ppa:ondrej/php
2020-05-31 21:45:39 -05:00
apt update
2023-12-15 11:06:03 -05:00
apt install acl curl apache2 fping git graphviz imagemagick libapache2-mod-fcgid mariadb-client mariadb-server mtr-tiny 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 python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip unzip traceroute
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
=== "NGINX"
2020-05-31 21:45:39 -05:00
```
2020-06-27 11:13:32 -05:00
dnf -y install epel-release
2022-07-29 15:48:49 +02:00
dnf -y install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
2020-10-04 23:46:29 +02:00
dnf module reset php
2022-07-29 15:48:49 +02:00
dnf module enable php:8.1
2021-10-06 07:29:47 -05:00
dnf install bash-completion cronie fping git ImageMagick mariadb-server mtr net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-gd php-gmp php-json php-mbstring php-process php-snmp php-xml php-zip php-mysqlnd python3 python3-PyMySQL python3-redis python3-memcached python3-pip python3-systemd rrdtool unzip
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
2024-05-07 23:26:45 -05:00
=== "Apache"
2020-05-31 21:45:39 -05:00
```
2020-06-27 11:13:32 -05:00
dnf -y install epel-release
2022-07-29 15:48:49 +02:00
dnf -y install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
2020-10-04 23:46:29 +02:00
dnf module reset php
2022-12-12 02:02:49 -06:00
dnf module enable php:remi-8.1
2023-09-27 20:11:26 +02:00
dnf install bash-completion cronie fping gcc git httpd ImageMagick mariadb-server mtr net-snmp net-snmp-utils nmap php-fpm php-cli php-common php-curl php-gd php-gmp php-json php-mbstring php-process php-snmp php-xml php-zip php-mysqlnd python3 python3-devel python3-PyMySQL python3-redis python3-memcached python3-pip python3-systemd rrdtool unzip
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
2024-05-07 23:26:45 -05:00
=== "Debian 12"
=== "NGINX"
2020-05-31 21:45:39 -05:00
```
2023-11-17 22:28:59 -05:00
apt install apt-transport-https lsb-release ca-certificates wget acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php8.2-cli php8.2-curl php8.2-fpm php8.2-gd php8.2-gmp php8.2-mbstring php8.2-mysql php8.2-snmp php8.2-xml php8.2-zip python3-dotenv python3-pymysql python3-redis python3-setuptools python3-systemd python3-pip rrdtool snmp snmpd unzip whois
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
## Add librenms user
2020-05-31 21:45:39 -05:00
2020-06-01 00:57:10 -05:00
```
2020-11-07 02:01:56 +01:00
useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
2020-06-01 00:57:10 -05:00
```
2020-05-31 21:45:39 -05:00
2020-10-09 14:52:02 +02:00
## Download LibreNMS
2020-05-31 21:45:39 -05:00
```
cd /opt
git clone https://github.com/librenms/librenms.git
```
2020-10-09 14:52:02 +02:00
## Set permissions
2020-05-31 21:45:39 -05:00
```
chown -R librenms:librenms /opt/librenms
2020-06-01 00:57:10 -05:00
chmod 771 /opt/librenms
2020-05-31 21:45:39 -05:00
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/
```
2020-10-09 14:52:02 +02:00
## Install PHP dependencies
2020-05-31 21:45:39 -05:00
```
su - librenms
2020-06-01 02:36:21 -05:00
./scripts/composer_wrapper.php install --no-dev
2020-05-31 21:45:39 -05:00
exit
```
2023-09-08 16:48:27 -05:00
Sometimes when there is a proxy used to gain internet access, the above script may fail. The workaround is to install the `composer` package manually. For a global installation:
2020-10-04 23:46:29 +02:00
```
wget https://getcomposer.org/composer-stable.phar
mv composer-stable.phar /usr/bin/composer
chmod +x /usr/bin/composer
```
2020-05-31 21:45:39 -05:00
2020-10-09 14:52:02 +02:00
## Set timezone
2020-05-31 21:45:39 -05:00
2021-02-09 00:29:04 +01:00
See <https://php.net/manual/en/timezones.php> for a list of supported
2020-06-03 02:21:36 -05:00
timezones. Valid examples are: "America/New_York", "Australia/Brisbane", "Etc/UTC".
Ensure date.timezone is set in php.ini to your preferred time zone.
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
```bash
vi /etc/php/8.3/fpm/php.ini
vi /etc/php/8.3/cli/php.ini
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
2022-08-05 00:58:03 +02:00
```bash
vi /etc/php/8.1/fpm/php.ini
vi /etc/php/8.1/cli/php.ini
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
2020-06-03 02:21:36 -05:00
```bash
2022-08-05 00:58:03 +02:00
vi /etc/php/8.1/fpm/php.ini
vi /etc/php/8.1/cli/php.ini
2020-06-03 02:21:36 -05:00
```
2020-10-09 14:52:02 +02:00
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
2020-06-29 16:17:07 -05:00
```
vi /etc/php.ini
```
2024-05-07 23:26:45 -05:00
=== "Debian 12"
2020-06-03 02:21:36 -05:00
```bash
2023-01-24 18:29:33 +01:00
vi /etc/php/8.2/fpm/php.ini
vi /etc/php/8.2/cli/php.ini
2020-06-03 02:21:36 -05:00
```
Remember to set the system timezone as well.
```
timedatectl set-timezone Etc/UTC
```
2020-10-09 14:52:02 +02:00
## Configure MariaDB
2020-05-31 21:45:39 -05:00
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
```
vi /etc/mysql/mariadb.conf.d/50-server.cnf
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
2022-08-05 00:58:03 +02:00
```
vi /etc/mysql/mariadb.conf.d/50-server.cnf
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
2020-05-31 21:45:39 -05:00
```
vi /etc/mysql/mariadb.conf.d/50-server.cnf
```
2020-06-29 16:17:07 -05:00
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
2020-05-31 21:45:39 -05:00
```
2020-06-01 02:36:21 -05:00
vi /etc/my.cnf.d/mariadb-server.cnf
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "Debian 12"
2020-06-29 16:17:07 -05:00
```
vi /etc/mysql/mariadb.conf.d/50-server.cnf
```
2020-10-09 14:52:02 +02:00
2020-06-01 00:57:10 -05:00
Within the `[mysqld]` section add:
2020-05-31 21:45:39 -05:00
2020-10-09 14:52:02 +02:00
```
2020-05-31 21:45:39 -05:00
innodb_file_per_table=1
lower_case_table_names=0
```
2023-04-07 20:04:47 +02:00
Then restart MariaDB
2020-05-31 21:45:39 -05:00
```
systemctl enable mariadb
systemctl restart mariadb
```
2023-04-07 20:04:47 +02:00
Start MariaDB client
2020-05-31 21:45:39 -05:00
2020-06-01 00:57:10 -05:00
```
mysql -u root
```
2020-05-31 21:45:39 -05:00
2020-06-01 00:57:10 -05:00
> NOTE: Change the 'password' below to something secure.
2020-05-31 21:45:39 -05:00
2020-06-01 00:57:10 -05:00
```sql
2021-03-28 16:23:08 +02:00
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2020-06-01 00:57:10 -05:00
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
exit
```
2020-10-09 14:52:02 +02:00
## Configure PHP-FPM
2020-06-01 00:57:10 -05:00
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
```bash
cp /etc/php/8.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/librenms.conf
vi /etc/php/8.3/fpm/pool.d/librenms.conf
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
2022-08-05 00:58:03 +02:00
```bash
cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/librenms.conf
vi /etc/php/8.1/fpm/pool.d/librenms.conf
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
2020-06-01 00:57:10 -05:00
```bash
2022-08-05 00:58:03 +02:00
cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/librenms.conf
vi /etc/php/8.1/fpm/pool.d/librenms.conf
2020-06-01 00:57:10 -05:00
```
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
2020-06-01 02:36:21 -05:00
```bash
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/librenms.conf
vi /etc/php-fpm.d/librenms.conf
```
2020-06-01 00:57:10 -05:00
2024-05-07 23:26:45 -05:00
=== "Debian 12"
2020-06-29 16:17:07 -05:00
```bash
2023-01-24 18:29:33 +01:00
cp /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/librenms.conf
vi /etc/php/8.2/fpm/pool.d/librenms.conf
2020-06-29 16:17:07 -05:00
```
2020-10-09 14:52:02 +02:00
Change `[www]` to `[librenms]` :
2020-06-01 00:57:10 -05:00
```
[librenms]
2020-10-09 14:52:02 +02:00
```
2020-06-01 00:57:10 -05:00
2020-10-09 14:52:02 +02:00
Change `user` and `group` to "librenms":
```
2020-06-01 00:57:10 -05:00
user = librenms
group = librenms
2020-10-09 14:52:02 +02:00
```
2020-06-01 00:57:10 -05:00
2023-02-14 15:35:09 +02:00
Change `listen` to a unique path that must match your webserver's config (`fastcgi_pass` for NGINX and `SetHandler` for Apache) :
2020-10-09 14:52:02 +02:00
```
2020-06-28 23:53:03 -05:00
listen = /run/php-fpm-librenms.sock
2020-06-01 00:57:10 -05:00
```
2020-06-28 20:05:04 -05:00
If there are no other PHP web applications on this server, you may remove www.conf to save some resources.
Feel free to tune the performance settings in librenms.conf to meet your needs.
2020-10-09 14:52:02 +02:00
## Configure Web Server
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
=== "NGINX"
```bash
vi /etc/nginx/conf.d/librenms.conf
```
Add the following config, edit `server_name` as required:
```nginx
server {
listen 80;
server_name librenms.example.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 ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm-librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
```
```bash
rm /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default
systemctl restart nginx
systemctl restart php8.3-fpm
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
=== "NGINX"
2022-08-05 00:58:03 +02:00
```bash
vi /etc/nginx/conf.d/librenms.conf
```
Add the following config, edit `server_name` as required:
```nginx
server {
listen 80;
server_name librenms.example.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 ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm-librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
```
```bash
rm /etc/nginx/sites-enabled/default
systemctl restart nginx
systemctl restart php8.1-fpm
```
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
=== "NGINX"
2020-05-31 21:45:39 -05:00
```bash
vi /etc/nginx/conf.d/librenms.conf
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Add the following config, edit `server_name` as required:
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```nginx
server {
listen 80;
server_name librenms.example.com;
root /opt/librenms/html;
index index.php;
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
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;
}
2020-06-25 11:18:26 -05:00
location ~ [^/]\.php(/|$) {
2020-06-01 00:57:10 -05:00
fastcgi_pass unix:/run/php-fpm-librenms.sock;
2020-06-25 11:18:26 -05:00
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
2020-05-31 21:45:39 -05:00
}
2020-06-25 11:18:26 -05:00
location ~ /\.(?!well-known).* {
2020-05-31 21:45:39 -05:00
deny all;
}
}
```
2020-06-01 00:57:10 -05:00
2020-05-31 21:45:39 -05:00
```bash
rm /etc/nginx/sites-enabled/default
systemctl restart nginx
2022-08-05 00:58:03 +02:00
systemctl restart php8.1-fpm
2020-05-31 21:45:39 -05:00
```
2020-06-01 00:57:10 -05:00
2024-05-07 23:26:45 -05:00
=== "Apache"
2020-05-31 21:45:39 -05:00
```bash
vi /etc/apache2/sites-available/librenms.conf
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Add the following config, edit `ServerName` as required:
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```apache
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
2020-06-01 00:57:10 -05:00
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
2020-10-09 14:52:02 +02:00
2020-06-01 00:57:10 -05:00
<FilesMatch ".+\.php$">
SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"
</FilesMatch>
2020-06-28 20:05:04 -05:00
</VirtualHost>
2020-05-31 21:45:39 -05:00
```
2020-06-01 00:57:10 -05:00
2020-05-31 21:45:39 -05:00
```bash
2020-06-01 00:57:10 -05:00
a2dissite 000-default
a2enmod proxy_fcgi setenvif rewrite
2020-05-31 21:45:39 -05:00
a2ensite librenms.conf
systemctl restart apache2
2022-08-05 00:58:03 +02:00
systemctl restart php8.1-fpm
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
=== "NGINX"
2020-05-31 21:45:39 -05:00
```
vi /etc/nginx/conf.d/librenms.conf
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Add the following config, edit `server_name` as required:
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```nginx
server {
listen 80;
server_name librenms.example.com;
root /opt/librenms/html;
index index.php;
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
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;
}
2020-06-25 11:24:18 -05:00
location ~ [^/]\.php(/|$) {
2020-06-01 02:36:21 -05:00
fastcgi_pass unix:/run/php-fpm-librenms.sock;
2020-06-25 11:24:18 -05:00
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
2020-05-31 21:45:39 -05:00
}
2020-06-25 11:24:18 -05:00
location ~ /\.(?!well-known).* {
2020-05-31 21:45:39 -05:00
deny all;
}
}
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
> NOTE: If this is the only site you are hosting on this server (it
> should be :)) then you will need to disable the default site.
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Delete the `server` section from `/etc/nginx/nginx.conf`
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
2020-06-01 00:57:10 -05:00
systemctl enable --now nginx
systemctl enable --now php-fpm
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "Apache"
2020-05-31 21:45:39 -05:00
Create the librenms.conf:
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
vi /etc/httpd/conf.d/librenms.conf
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Add the following config, edit `ServerName` as required:
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```apache
<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
2020-06-03 02:21:36 -05:00
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
2020-10-09 14:52:02 +02:00
2020-06-03 02:21:36 -05:00
<FilesMatch ".+\.php$">
SetHandler "proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost"
</FilesMatch>
2020-06-28 20:05:04 -05:00
</VirtualHost>
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
> NOTE: If this is the only site you are hosting on this server (it
> should be :)) then you will need to disable the default site. `rm -f /etc/httpd/conf.d/welcome.conf`
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
systemctl enable --now httpd
2020-06-03 02:21:36 -05:00
systemctl enable --now php-fpm
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "Debian 12"
=== "NGINX"
2020-06-29 16:17:07 -05:00
```bash
vi /etc/nginx/sites-enabled/librenms.vhost
```
2020-10-09 14:52:02 +02:00
2020-06-29 16:17:07 -05:00
Add the following config, edit `server_name` as required:
2020-10-09 14:52:02 +02:00
2020-06-29 16:17:07 -05:00
```nginx
server {
listen 80;
server_name librenms.example.com;
root /opt/librenms/html;
index index.php;
2020-10-09 14:52:02 +02:00
2020-06-29 16:17:07 -05:00
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 ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm-librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
```
2020-10-09 14:52:02 +02:00
2020-06-29 16:17:07 -05:00
```bash
rm /etc/nginx/sites-enabled/default
systemctl reload nginx
2023-01-24 18:29:33 +01:00
systemctl restart php8.2-fpm
2020-06-29 16:17:07 -05:00
```
2020-10-09 14:52:02 +02:00
## SELinux
2020-05-31 21:45:39 -05:00
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
SELinux not enabled by default
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
2022-08-05 00:58:03 +02:00
SELinux not enabled by default
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
2020-05-31 21:45:39 -05:00
SELinux not enabled by default
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
2020-06-14 16:19:58 -05:00
Install the policy tool for SELinux:
2020-06-14 16:18:58 -05:00
2020-06-14 16:19:58 -05:00
```
dnf install policycoreutils-python-utils
```
2020-06-14 16:18:58 -05:00
2022-02-09 00:02:28 +01:00
<h3>Configure the contexts needed by LibreNMS</h3>
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
2020-06-01 13:52:32 -05:00
semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/html(/.*)?'
2022-07-22 15:32:37 +02:00
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/(rrd|storage)(/.*)?'
semanage fcontext -a -t httpd_log_t "/opt/librenms/logs(/.*)?"
2024-05-01 11:21:55 +02:00
semanage fcontext -a -t httpd_cache_t '/opt/librenms/cache(/.*)?'
2021-09-10 15:19:35 +02:00
semanage fcontext -a -t bin_t '/opt/librenms/librenms-service.py'
2020-06-01 13:52:32 -05:00
restorecon -RFvv /opt/librenms
2020-05-31 21:45:39 -05:00
setsebool -P httpd_can_sendmail=1
setsebool -P httpd_execmem 1
2020-06-28 20:05:04 -05:00
chcon -t httpd_sys_rw_content_t /opt/librenms/.env
2020-05-31 21:45:39 -05:00
```
2020-10-09 14:52:02 +02:00
2022-02-09 00:02:28 +01:00
<h3>Allow fping</h3>
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Create the file http_fping.tt with the following contents. You can
create this file anywhere, as it is a throw-away file. The last step
in this install procedure will install the module in the proper
location.
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
module http_fping 1.0;
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
require {
type httpd_t;
class capability net_raw;
class rawip_socket { getopt create setopt write read };
}
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
#============= httpd_t ==============
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket { getopt create setopt write read };
```
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
Then run these commands
2020-10-09 14:52:02 +02:00
2020-05-31 21:45:39 -05:00
```
checkmodule -M -m -o http_fping.mod http_fping.tt
semodule_package -o http_fping.pp -m http_fping.mod
semodule -i http_fping.pp
```
2020-10-09 14:52:02 +02:00
2020-06-01 13:52:32 -05:00
Additional SELinux problems may be found by executing the following command
2020-10-09 14:52:02 +02:00
2020-06-01 13:52:32 -05:00
```
audit2why < /var/log/audit/audit.log
```
2020-05-31 21:45:39 -05:00
2024-05-07 23:26:45 -05:00
=== "Debian 12"
2020-06-29 16:17:07 -05:00
SELinux not enabled by default
2020-10-09 14:52:02 +02:00
## Allow access through firewall
2024-08-30 16:41:27 +03:30
=== "Ubuntu 24.04"
Firewall not enabled by default
2020-05-31 21:45:39 -05:00
2024-05-07 23:26:45 -05:00
=== "Ubuntu 22.04"
2022-08-05 00:58:03 +02:00
Firewall not enabled by default
2024-05-07 23:26:45 -05:00
=== "Ubuntu 20.04"
2020-05-31 21:45:39 -05:00
Firewall not enabled by default
2024-05-07 23:26:45 -05:00
=== "CentOS 8"
2020-06-03 02:21:36 -05:00
2020-05-31 21:45:39 -05:00
```
2020-06-01 13:52:32 -05:00
firewall-cmd --zone public --add-service http --add-service https
firewall-cmd --permanent --zone public --add-service http --add-service https
2020-05-31 21:45:39 -05:00
```
2024-05-07 23:26:45 -05:00
=== "Debian 12"
2020-06-29 16:17:07 -05:00
Firewall not enabled by default
2020-10-09 14:52:02 +02:00
## Enable lnms command completion
2020-06-08 16:22:35 +02:00
This feature grants you the opportunity to use tab for completion on lnms commands as you would
for normal linux commands.
2020-06-03 02:21:36 -05:00
```
2021-01-19 20:37:28 -06:00
ln -s /opt/librenms/lnms /usr/bin/lnms
2020-06-03 02:21:36 -05:00
cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
```
2020-10-09 14:52:02 +02:00
## Configure snmpd
2020-05-31 21:45:39 -05:00
```
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
```
```
vi /etc/snmp/snmpd.conf
```
Edit the text which says `RANDOMSTRINGGOESHERE` and set your own community string.
```
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
systemctl enable snmpd
systemctl restart snmpd
```
2020-10-09 14:52:02 +02:00
## Cron job
2020-05-31 21:45:39 -05:00
```
2023-04-24 10:04:50 +02:00
cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms
2020-05-31 21:45:39 -05:00
```
> NOTE: Keep in mind that cron, by default, only uses a very limited
> set of environment variables. You may need to configure proxy
> variables for the cron invocation. Alternatively adding the proxy
> settings in config.php is possible too. The config.php file will be
> created in the upcoming steps. Review the following URL after you
> finished librenms install steps:
2020-11-27 23:34:58 +01:00
> <@= config.site_url =@/Support/Configuration/#proxy-support>
2020-05-31 21:45:39 -05:00
2023-04-24 10:04:50 +02:00
## Enable the scheduler
```
cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
systemctl enable librenms-scheduler.timer
systemctl start librenms-scheduler.timer
```
2020-10-09 14:52:02 +02:00
## Copy logrotate config
2020-05-31 21:45:39 -05:00
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:
```
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
```
2020-10-09 14:52:02 +02:00
## Web installer
2020-05-31 21:45:39 -05:00
Now head to the web installer and follow the on-screen instructions.
2020-06-27 11:13:32 -05:00
<http://librenms.example.com/install>
2020-05-31 21:45:39 -05:00
The web installer might prompt you to create a `config.php` file in
your librenms install location manually, copying the content displayed
on-screen to the file. If you have to do this, please remember to set
the permissions on config.php after you copied the on-screen contents
to the file. Run:
```
chown librenms:librenms /opt/librenms/config.php
```
2020-10-09 14:52:02 +02:00
## Final steps
2020-05-31 21:45:39 -05:00
That's it! You now should be able to log in to
<http://librenms.example.com/>. Please note that we have not covered
HTTPS setup in this example, so your LibreNMS install is not secure
by default. Please do not expose it to the public Internet unless
you have configured HTTPS and taken appropriate web server hardening
steps.
2020-10-09 14:52:02 +02:00
## Add the first device
2020-05-31 21:45:39 -05:00
We now suggest that you add localhost as your first device from within the WebUI.
2020-10-09 14:52:02 +02:00
## Troubleshooting
2020-05-31 21:45:39 -05:00
If you ever have issues with your install, run validate.php:
```
sudo su - librenms
./validate.php
```
There are various options for getting help listed on the LibreNMS web
site: <https://www.librenms.org/#support >
2020-10-09 14:52:02 +02:00
## What next?
2020-05-31 21:45:39 -05:00
Now that you've installed LibreNMS, we'd suggest that you have a read
of a few other docs to get you going:
2020-11-27 23:34:58 +01:00
- [Performance tuning ](../Support/Performance.md )
2022-02-09 00:02:28 +01:00
- [Alerting ](../Alerting/index.md )
2020-11-27 23:34:58 +01:00
- [Device Groups ](../Extensions/Device-Groups.md )
- [Auto discovery ](../Extensions/Auto-Discovery.md )
2020-05-31 21:45:39 -05:00
2020-10-09 14:52:02 +02:00
## Closing
2020-05-31 21:45:39 -05:00
We hope you enjoy using LibreNMS. If you do, it would be great if you
would consider opting into the stats system we have, please see [this
2020-11-27 23:34:58 +01:00
page](../General/Callback-Stats-and-Privacy.md) on
2020-05-31 21:45:39 -05:00
what it is and how to enable it.
If you would like to help make LibreNMS better there are [many ways to
2023-07-20 15:45:13 +02:00
help](../Support/FAQ.md#a -namefaq9-what-can-i-do-to-help). You
2020-11-27 23:34:58 +01:00
can also [back LibreNMS on Open Collective ](https://t.libren.ms/donations ).