顯示頁面舊版反向連結Fold/unfold all回到頁頂 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ===== Ubuntu 20.04 安裝程序 ===== * 安裝必要的套件 <cli> apt install software-properties-common add-apt-repository universe apt update apt install acl curl composer fping git graphviz imagemagick mailutils mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.4-cli php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-snmp php7.4-xml php7.4-zip rrdtool snmp snmpd whois unzip python3-pip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd </cli> * 新增 librenms 帳號<cli> useradd librenms -d /opt/librenms -M -r -s "$(which bash)" </cli> * 下載 LibreNMS 系統<cli> cd /opt git clone https://github.com/librenms/librenms.git </cli> * 設定 librenms 權限<cli> chown -R librenms:librenms /opt/librenms chmod 771 /opt/librenms 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/ </cli> * 安裝 PHP 相關套件<cli> su - librenms ./scripts/composer_wrapper.php install --no-dev exit </cli> * 安裝 php composer<cli> wget https://getcomposer.org/composer-stable.phar mv composer-stable.phar /usr/bin/composer chmod +x /usr/bin/composer </cli> * 設定時區資料<cli> vi /etc/php/7.4/fpm/php.ini vi /etc/php/7.4/cli/php.ini </cli><file> : date.timezone = "Asia/Taipei" : </file><cli> timedatectl set-timezone Asia/Taipei </cli> * 設定 MariaDB <cli> vi /etc/mysql/mariadb.conf.d/50-server.cnf -- [mysqld] : innodb_file_per_table=1 lower_case_table_names=0 : -- systemctl enable mariadb systemctl restart mariadb </cli> * 修改 DB 密碼 **Password**<cli> mysql -u root -- CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'librenms'@'localhost' IDENTIFIED BY '**Password**'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost'; FLUSH PRIVILEGES; exit </cli> * 設定 PHP-FPM<cli> cp /etc/php/7.4/fpm/pool.d/www.conf /etc/php/7.4/fpm/pool.d/librenms.conf vi /etc/php/7.4/fpm/pool.d/librenms.conf </cli> - 將 [www] 改成 [librenms] - 將 user 和 group 改成 "librenms"<cli> user = librenms group = librenms </cli> - 將 listen 改成 /run/php-fpm-librenms.sock<cli> listen = /run/php-fpm-librenms.sock </cli> * 設定 Nginx 改 server_name 為實際的網址或 IP Exp. 10.20.0.34<cli> vi /etc/nginx/conf.d/librenms.conf </cli><file> server { listen 80; server_name 10.20.0.34; 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; } } </file> * 重新啟動 nginx<cli> rm /etc/nginx/sites-enabled/default systemctl restart nginx systemctl restart php7.4-fpm </cli> * 啟動 lnms<cli> ln -s /opt/librenms/lnms /usr/bin/lnms cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/ </cli> * 設定 snmpd <cli> cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf vi /etc/snmp/snmpd.conf --- 將 RANDOMSTRINGGOESHERE 改成自己的 snmp 密碼 com2sec readonly default RANDOMSTRINGGOESHERE : -- 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 </cli> * 設定 crontab <cli> cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms </cli> * 設定 logrotate<cli> cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms </cli> * 開啟網頁進行設定 Exp. http://10.20.0.34 - 檢查設定 - 設定資料庫與匯入基本資料 - 建立管理者帳號密碼 * 如果有遇到問題可以執行以下語法進行檢測<cli> sudo su - librenms ./validate.php </cli>如果沒問題會顯示類似如下結果:<cli> root@ct-librenms:/opt# sudo su - librenms librenms@ct-librenms:~$ ./validate.php ==================================== Component | Version --------- | ------- LibreNMS | 21.4.0-3-gcea6f13bf DB Schema | 2021_04_08_151101_add_foreign_keys_to_port_group_port_table (208) PHP | 7.4.3 Python | 3.8.5 MySQL | 10.3.25-MariaDB-0ubuntu0.20.04.1 RRDTool | 1.7.2 SNMP | NET-SNMP 5.8 ==================================== [OK] Composer Version: 2.0.12 [OK] Dependencies up-to-date. [WARN] You have no devices. [FIX]: Consider adding a device such as localhost: /addhost [OK] Database connection successful [OK] Database schema correct librenms@ct-librenms:~$ </cli> tech/librenms/ubuntu20_04.txt 上一次變更: 2022/01/13 23:36由 jonathan