0415.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  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. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  7. <script type="text/javascript">
  8. $(function(){
  9. $('textarea').each(function(i,e){
  10. theTextarea = $(this);
  11. theTextarea.height((theTextarea[0].scrollHeight-5) +'px');
  12. });
  13. $('li').each(function(i,e){
  14. if(!$(this).hasClass('noCheckbox')){
  15. var uuid = 'li_' + Math.floor(Math.random() * Math.floor(1000000)).toString() + '_' + i.toString();
  16. $(this).contents().wrap('<span id="'+ uuid +'"><label for="cb_'+ uuid +'"></label></span>');
  17. $(this).prepend('<input type="checkbox" class="completeBox" id="cb_' + uuid +'" rel="'+ uuid +'" />')
  18. }
  19. });
  20. $('code,div.codeBlock,textarea.codeBlock').each(function(i,e){
  21. theElement = $(this);
  22. var lines = theElement.html().split("\n");
  23. theElement.empty();
  24. for(l=0;l<lines.length;l++){
  25. if($.trim(lines[l]) != '' && $.trim(lines[l]).substr(0,1) != '#' && $.trim(lines[l]).indexOf(' #') == -1 && lines[l].substr(0, 4).toUpperCase() != 'REM '){
  26. theElement.append('<input type="image" src="images/clipboard.png" value="" class="copy-text" rel="copy_'+ i +'_'+ l +'" data-clipboard-text="'+ $.trim(lines[l].replace(/"/g, '&quot;')) +'" /><span id="copy_'+ i +'_'+ l +'">'+ lines[l] +'</span>');
  27. } else {
  28. theElement.append(lines[l]);
  29. }
  30. }
  31. });
  32. $(document).on('click','input.copy-text',function(){
  33. theButton = $(this);
  34. $('input.copy-text').attr('src','images/clipboard.png');
  35. $('span.copy-animation,span.copy-animation-ps').removeClass('copy-animation copy-animation-ps');
  36. try {
  37. if($('#'+ theButton.attr('rel')).parent('div').hasClass('PS')){
  38. $('#'+ theButton.attr('rel')).addClass('copy-animation-ps');
  39. } else if($('#'+ theButton.attr('rel')).parent('div').hasClass('CMD')){
  40. $('#'+ theButton.attr('rel')).addClass('copy-animation-cmd');
  41. } else {
  42. $('#'+ theButton.attr('rel')).addClass('copy-animation');
  43. }
  44. navigator.clipboard.writeText(theButton.data('clipboard-text').replace(/<[^>]*>?/gm, ''));
  45. theButton.attr('src','images/clipboard_active.png');
  46. } catch(err) {
  47. }
  48. return false;
  49. });
  50. $(document).on('click','input.completeBox',function(){
  51. theBox = $(this);
  52. $('#'+ theBox.attr('rel')).addClass('strikethrough');
  53. theBox.prop('disabled',true);
  54. theBox.parent('li').prevAll().each(function(i,e){
  55. theLI = $(this);
  56. if(theLI.find('input[type=checkbox]').not(':checked')){
  57. $('#'+ theLI.find('input[type=checkbox]').attr('rel')).addClass('strikethrough');
  58. theLI.find('input[type=checkbox]').prop('checked',true).prop('disabled',true);
  59. }
  60. });
  61. });
  62. if(window.self !== window.top){
  63. window.parent.$('iframe.stepsFrame').height((this['scrollingElement']['scrollHeight']+20) +'px');
  64. }
  65. });
  66. </script>
  67. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  68. </head>
  69. <body>
  70. <div id="gridContainer">
  71. <div class="topMargin"></div>
  72. <div id="listName" class="topMargin">
  73. <h1>Install LibreNMS on Debian/Ubuntu</h1>
  74. </div>
  75. <div></div>
  76. <div id="content">
  77. <ol>
  78. <li>Log into the Debian device</li>
  79. <li>Run the following commands in a terminal:
  80. <div class="codeBlock"># update software repositories<br />
  81. sudo apt update<br />
  82. # install software updates<br />
  83. sudo apt upgrade -y<br />
  84. # install pre-requisites<br />
  85. 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 />
  86. # install Apache and MySQL<br />
  87. sudo apt install apache2 libapache2-mod-fcgid mariadb-server mariadb-client -y<br />
  88. # install PHP components<br />
  89. 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 />
  90. # create librenms user<br />
  91. sudo useradd librenms -d /opt/librenms -M -r -s &quot;$(which bash)&quot;<br />
  92. # clone librenms github repo<br />
  93. sudo git clone https://github.com/librenms/librenms.git /opt/librenms<br />
  94. # set permissions<br />
  95. sudo chown -R librenms:librenms /opt/librenms<br />
  96. sudo chmod 771 /opt/librenms<br />
  97. sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/<br />
  98. sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/<br />
  99. # install PHP dependencies<br />
  100. sudo su - librenms<br />
  101. ./scripts/composer_wrapper.php install --no-dev<br />
  102. exit<br />
  103. # set time zone for PHP fpm<br />
  104. sudo nano /etc/php/7.3/fpm/php.ini</div>
  105. </li>
  106. <li>Press CTRL+W to search &gt; type timezone &gt; Press Enter</li>
  107. <li>Remove the ; to uncomment the line</li>
  108. <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>
  109. <li>Press CTRL+O, Enter, CTRL+X to write the changes to php.ini</li>
  110. <li>Continue with the following commands in a terminal:
  111. <div class="codeBlock"># set time zone for PHP cli<br />
  112. sudo nano /etc/php/7.3/cli/php.ini</div>
  113. </li>
  114. <li>Press CTRL+W to search &gt; type timezone &gt; Press Enter</li>
  115. <li>Remove the ; to uncomment the line</li>
  116. <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>
  117. <li>Press CTRL+O, Enter, CTRL+X to write the changes to php.ini</li>
  118. <li>Continue with the following commands in a terminal:</li>
  119. <li>
  120. <div class="codeBlock"># set system time zone<br />
  121. sudo timedatectl set-timezone America/New_York<br />
  122. # edit mariaDB configuration<br />
  123. sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf</div>
  124. </li>
  125. <li>Paste the following under the [mysqld] section
  126. <p>innodb_file_per_table=1<br />
  127. lower_case_table_names=0</p>
  128. </li>
  129. <li>Press CTRL+O, Enter, CTRL+X to write the changes to 50-server.cnf</li>
  130. <li>Continue with the following commands in a terminal:
  131. <div class="codeBlock"># restart mariadb service<br />
  132. sudo systemctl restart mariadb<br />
  133. # configure the MySQL database<br />
  134. sudo su<br />
  135. mysql_secure_installation</div>
  136. </li>
  137. <li>Press Enter to login as root</li>
  138. <li>Type Y and press Enter to set a root password, type the password twice to confirm</li>
  139. <li>Type Y and press Enter to remove anonymous users</li>
  140. <li>Type Y and press Enter to disallow root login remotely</li>
  141. <li>Type Y and press Enter to remove the test database</li>
  142. <li>Type Y and press Enter to reload privilege tables</li>
  143. <li>Run the following command to login into MySQL:
  144. <div class="codeBlock">mysql -u root -p</div>
  145. </li>
  146. <li>Authenticate with the root password set earlier</li>
  147. <li>Run the following commands to create the LibreNMS database and database user
  148. <div class="codeBlock">CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<br />
  149. CREATE USER &#39;librenms_rw&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;Libr3NM$!&#39;;<br />
  150. GRANT ALL PRIVILEGES ON librenms.* TO &#39;librenms_rw&#39;@&#39;localhost&#39;;<br />
  151. FLUSH PRIVILEGES;<br />
  152. EXIT;<br />
  153. exit</div>
  154. </li>
  155. <li>Continue with the following commands:
  156. <div class="codeBlock"># make a copy of www.conf<br />
  157. sudo cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf<br />
  158. # edit librenms.conf<br />
  159. sudo nano /etc/php/7.3/fpm/pool.d/librenms.conf</div>
  160. </li>
  161. <li>Replace [www] with [librenms]</li>
  162. <li>Change the user and group to librenms
  163. <p>user = librenms<br />
  164. group = librenms</p>
  165. </li>
  166. <li>Change the listen to php-fpm-librenms.sock
  167. <p>listen = /run/php-fpm-librenms.sock</p>
  168. </li>
  169. <li>Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf</li>
  170. <li>Continue with the following commands:
  171. <div class="codeBlock"># create librenms apache conf<br />
  172. sudo nano /etc/apache2/sites-available/librenms.conf</div>
  173. </li>
  174. <li>Paste the following configuration into librenms.vhost
  175. <p>&lt;VirtualHost *:80&gt;<br />
  176. DocumentRoot /opt/librenms/html/<br />
  177. #ServerName librenms.example.com</p>
  178. <p>AllowEncodedSlashes NoDecode<br />
  179. &lt;Directory &quot;/opt/librenms/html/&quot;&gt;<br />
  180. Require all granted<br />
  181. AllowOverride All<br />
  182. Options FollowSymLinks MultiViews<br />
  183. &lt;/Directory&gt;</p>
  184. <p># Enable http authorization headers<br />
  185. &lt;IfModule setenvif_module&gt;<br />
  186. SetEnvIfNoCase ^Authorization$ &quot;(.+)&quot; HTTP_AUTHORIZATION=$1<br />
  187. &lt;/IfModule&gt;</p>
  188. <p>&lt;FilesMatch &quot;.+\.php$&quot;&gt;<br />
  189. SetHandler &quot;proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost&quot;<br />
  190. &lt;/FilesMatch&gt;<br />
  191. &lt;/VirtualHost&gt;</p>
  192. </li>
  193. <li>Press CTRL+O, Enter, CTRL+X to write the changes to librenms.conf</li>
  194. <li>Continue with the following commands:
  195. <div class="codeBlock"># enable the librenms site and reload apache<br />
  196. sudo a2dissite 000-default<br />
  197. sudo a2enmod proxy_fcgi setenvif rewrite<br />
  198. sudo a2ensite librenms.conf<br />
  199. sudo systemctl restart apache2<br />
  200. sudo systemctl restart php7.3-fpm<br />
  201. # install dispatcher service<br />
  202. sudo su - librenms<br />
  203. pip3 install -r requirements.txt<br />
  204. exit<br />
  205. sudo cp /opt/librenms/misc/librenms.service /etc/systemd/system/librenms.service<br />
  206. sudo systemctl enable --now librenms.service<br />
  207. # enable snmp<br />
  208. sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf<br />
  209. sudo nano /etc/snmp/snmpd.conf</div>
  210. </li>
  211. <li>Change RANDOMSTRINGGOESHERE to a unique community string to use for SNMP</li>
  212. <li>Press CTRL+O, Enter, CTRL+X to write the changes to snmpd.conf</li>
  213. <li>Continue with the following commands:
  214. <div class="codeBlock"># download librenms snmp<br />
  215. sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro<br />
  216. # set permissions<br />
  217. sudo chmod +x /usr/bin/distro<br />
  218. # restart snmp service<br />
  219. sudo systemctl enable snmpd<br />
  220. sudo systemctl restart snmpd</div>
  221. </li>
  222. <li>Open a web browser and navigate to http://DNSorIP//install</li>
  223. <li>The LibreNMS setup screen should be displayed</li>
  224. <li>Click the Configure Database icon</li>
  225. <li>Select MySQL and fill out the database connection information as follows
  226. <p>Host: localhost<br />
  227. Port: 3306<br />
  228. User: librenms_rw<br />
  229. Password: Libr3NM$!<br />
  230. Database Name: librenms</p>
  231. </li>
  232. <li>Click the Check Credentials button</li>
  233. <li>Click the Build Database button</li>
  234. <li>Once the database has been created successfully, click the Created Admin User icon</li>
  235. <li>Enter a username, password and email address &gt; Click the Add User button</li>
  236. <li>Click the Finish Install icon</li>
  237. <li>Click the validate your install link</li>
  238. <li>Log in using the admin user credentials created earlier</li>
  239. <li>Welcome to LibreNMS</li>
  240. </ol>
  241. <p>Source: <a href="https://docs.librenms.org/Installation/Install-LibreNMS/" target="_blank">https://docs.librenms.org/Installation/Install-LibreNMS/</a></p>
  242. <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>
  243. </div>
  244. </div>
  245. </body>
  246. </html>