0415.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Install LibreNMS on Debian/Ubuntu</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Browser Based,Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,Web Based,Web Based Tools,Debian,Homelab,LibreNMS,Linux,MariaDB,MySQL,NMS,Network Monitoring System,PHP,PHP Based Application,PHP Server Monitor,Ubuntu,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Install LibreNMS on Debian/Ubuntu">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="06/09/2024 01:56:43 PM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Install LibreNMS on Debian/Ubuntu</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <ol>
  26. <li>Log into the Debian device</li>
  27. <li>Run the following commands in a terminal:
  28. <div class="codeBlock"># update software repositories<br />
  29. sudo apt update<br />
  30. # install software updates<br />
  31. sudo apt upgrade -y<br />
  32. # install pre-requisites<br />
  33. 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<br />
  34. # install Apache and MySQL<br />
  35. sudo apt install apache2 libapache2-mod-fcgid mariadb-server mariadb-client -y<br />
  36. # install PHP components<br />
  37. 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<br />
  38. # create librenms user<br />
  39. sudo useradd librenms -d /opt/librenms -M -r -s &quot;$(which bash)&quot;<br />
  40. # clone librenms github repo<br />
  41. sudo git clone https://github.com/librenms/librenms.git /opt/librenms<br />
  42. # set permissions<br />
  43. sudo chown -R librenms:librenms /opt/librenms<br />
  44. sudo chmod 771 /opt/librenms<br />
  45. sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/<br />
  46. sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/<br />
  47. # install composer dependencies<br />
  48. sudo su - librenms<br />
  49. ./scripts/composer_wrapper.php install --no-dev<br />
  50. exit<br />
  51. # set time zone for PHP fpm<br />
  52. sudo nano /etc/php/7.3/fpm/php.ini</div>
  53. </li>
  54. <li>Press CTRL+W to search &gt; type timezone &gt; Press Enter</li>
  55. <li>Remove the ; to uncomment the line</li>
  56. <li>Type in a valid timezone (<a href="https://php.net/manual/en/timezones.php" target="_blank">https://php.net/manual/en/timezones.php</a>)</li>
  57. <li>Press CTRL+O, Enter, CTRL+X to write the changes to php.ini</li>
  58. <li>Continue with the following commands in a terminal:
  59. <div class="codeBlock"># set time zone for PHP cli<br />
  60. sudo nano /etc/php/7.3/cli/php.ini</div>
  61. </li>
  62. <li>Press CTRL+W to search &gt; type timezone &gt; Press Enter</li>
  63. <li>Remove the ; to uncomment the line</li>
  64. <li>Type in a valid timezone (<a href="https://php.net/manual/en/timezones.php" target="_blank">https://php.net/manual/en/timezones.php</a>)</li>
  65. <li>Press CTRL+O, Enter, CTRL+X to write the changes to php.ini</li>
  66. <li>Continue with the following commands in a terminal:</li>
  67. <li>
  68. <div class="codeBlock"># set system time zone<br />
  69. sudo timedatectl set-timezone America/New_York<br />
  70. # edit mariaDB configuration<br />
  71. sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf</div>
  72. </li>
  73. <li>Paste the following under the [mysqld] section
  74. <p>innodb_file_per_table=1<br />
  75. lower_case_table_names=0</p>
  76. </li>
  77. <li>Press CTRL+O, Enter, CTRL+X to write the changes to 50-server.cnf</li>
  78. <li>Continue with the following commands in a terminal:
  79. <div class="codeBlock"># restart mariadb service<br />
  80. sudo systemctl restart mariadb<br />
  81. # configure the MySQL database<br />
  82. sudo su<br />
  83. mysql_secure_installation</div>
  84. </li>
  85. <li>Press Enter to login as root</li>
  86. <li>Type Y and press Enter to set a root password, type the password twice to confirm</li>
  87. <li>Type Y and press Enter to remove anonymous users</li>
  88. <li>Type Y and press Enter to disallow root login remotely</li>
  89. <li>Type Y and press Enter to remove the test database</li>
  90. <li>Type Y and press Enter to reload privilege tables</li>
  91. <li>Run the following command to login into MySQL:
  92. <div class="codeBlock">mysql -u root -p</div>
  93. </li>
  94. <li>Authenticate with the root password set earlier</li>
  95. <li>Run the following commands to create the LibreNMS database and database user
  96. <div class="codeBlock">CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<br />
  97. CREATE USER &#39;librenms_rw&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;Libr3NM$!&#39;;<br />
  98. GRANT ALL PRIVILEGES ON librenms.* TO &#39;librenms_rw&#39;@&#39;localhost&#39;;<br />
  99. FLUSH PRIVILEGES;<br />
  100. EXIT;<br />
  101. exit</div>
  102. </li>
  103. <li>Continue with the following commands:
  104. <div class="codeBlock"># make a copy of www.conf<br />
  105. sudo cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf<br />
  106. # edit librenms.conf<br />
  107. sudo nano /etc/php/7.3/fpm/pool.d/librenms.conf</div>
  108. </li>
  109. <li>Replace [www] with [librenms]</li>
  110. <li>Change the user and group to librenms
  111. <p>user = librenms<br />
  112. group = librenms</p>
  113. </li>
  114. <li>Change the listen to php-fpm-librenms.sock
  115. <p>listen = /run/php-fpm-librenms.sock</p>
  116. </li>
  117. <li>Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf</li>
  118. <li>Continue with the following commands:
  119. <div class="codeBlock"># create librenms apache conf<br />
  120. sudo nano /etc/apache2/sites-available/librenms.conf</div>
  121. </li>
  122. <li>Paste the following configuration into librenms.vhost
  123. <p>&lt;VirtualHost *:80&gt;<br />
  124. DocumentRoot /opt/librenms/html/<br />
  125. #ServerName librenms.example.com</p>
  126. <p>AllowEncodedSlashes NoDecode<br />
  127. &lt;Directory &quot;/opt/librenms/html/&quot;&gt;<br />
  128. Require all granted<br />
  129. AllowOverride All<br />
  130. Options FollowSymLinks MultiViews<br />
  131. &lt;/Directory&gt;</p>
  132. <p># Enable http authorization headers<br />
  133. &lt;IfModule setenvif_module&gt;<br />
  134. SetEnvIfNoCase ^Authorization$ &quot;(.+)&quot; HTTP_AUTHORIZATION=$1<br />
  135. &lt;/IfModule&gt;</p>
  136. <p>&lt;FilesMatch &quot;.+\.php$&quot;&gt;<br />
  137. SetHandler &quot;proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost&quot;<br />
  138. &lt;/FilesMatch&gt;<br />
  139. &lt;/VirtualHost&gt;</p>
  140. </li>
  141. <li>Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf</li>
  142. <li>Continue with the following commands:
  143. <div class="codeBlock"># enable the librenms site and reload apache<br />
  144. sudo a2dissite 000-default<br />
  145. sudo a2enmod proxy_fcgi setenvif rewrite<br />
  146. sudo a2ensite librenms.conf<br />
  147. sudo systemctl restart apache2<br />
  148. sudo systemctl restart php7.3-fpm<br />
  149. # install dispatcher service<br />
  150. sudo su - librenms<br />
  151. pip3 install -r requirements.txt<br />
  152. exit<br />
  153. sudo cp /opt/librenms/misc/librenms.service /etc/systemd/system/librenms.service<br />
  154. sudo systemctl enable --now librenms.service<br />
  155. # enable snmp<br />
  156. sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf<br />
  157. sudo nano /etc/snmp/snmpd.conf</div>
  158. </li>
  159. <li>Change RANDOMSTRINGGOESHERE to a unique community string to use for SNMP</li>
  160. <li>Press CTRL+O, Enter, CTRL+X to write the changes to snmpd.conf</li>
  161. <li>Continue with the following commands:
  162. <div class="codeBlock"># download librenms snmp<br />
  163. sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro<br />
  164. # set permissions<br />
  165. sudo chmod +x /usr/bin/distro<br />
  166. # restart snmp service<br />
  167. sudo systemctl enable snmpd<br />
  168. sudo systemctl restart snmpd</div>
  169. </li>
  170. <li>Open a web browser and navigate to http://DNSorIP//install</li>
  171. <li>The LibreNMS setup screen should be displayed</li>
  172. <li>Click the Configure Database icon</li>
  173. <li>Select MySQL and fill out the database connection information as follows
  174. <p>Host: localhost<br />
  175. Port: 3306<br />
  176. User: librenms_rw<br />
  177. Password: Libr3NM$!<br />
  178. Database Name: librenms</p>
  179. </li>
  180. <li>Click the Check Credentials button</li>
  181. <li>Click the Build Database button</li>
  182. <li>Once the database has been created successfully, click the Created Admin User icon</li>
  183. <li>Enter a username, password and email address &gt; Click the Add User button</li>
  184. <li>Click the Finish Install icon</li>
  185. <li>Click the validate your install link</li>
  186. <li>Log in using the admin user credentials created earlier</li>
  187. <li>Welcome to LibreNMS</li>
  188. </ol>
  189. <p>Source: <a href="https://docs.librenms.org/Installation/Install-LibreNMS/" target="_blank">https://docs.librenms.org/Installation/Install-LibreNMS/</a></p>
  190. <p>Check out <strong>for day in life</strong> on YouTube for more on LibreNMS: <a href="https://www.youtube.com/playlist?list=PLxiGkbpIzunT_YOwUEukOB6DpF8N8MXkQ" target="_blank">https://www.youtube.com/playlist?list=PLxiGkbpIzunT_YOwUEukOB6DpF8N8MXkQ</a></p> </div>
  191. </div>
  192. </body>
  193. </html>