root. Tutorial ini sudah termasuk perbaikan untuk dependensi PHP dan pengaturan Timezone otomatis (WITA).
Langkah ini memastikan sistem mendapatkan PHP versi terbaru (8.2) untuk menghindari error composer, meskipun menggunakan Debian 11.
apt update && apt upgrade -y
apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 curl wget unzip git
# Tambahkan Repo PHP Sury (Fix untuk Debian 11/12)
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
apt update
Install paket dependencies lengkap, web server, dan membuat user sistem khusus.
apt install -y acl fping mariadb-client mariadb-server mtr-tiny nginx-full nmap \
php8.2 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-pip \
python3-psutil python3-pymysql python3-redis python3-setuptools python3-systemd \
rrdtool snmp snmpd whois cron
# Set PHP 8.2 sebagai default system
update-alternatives --set php /usr/bin/php8.2
# Buat user librenms
useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
Mengambil source code dari GitHub dan mengatur hak akses folder.
cd /opt
git clone https://github.com/librenms/librenms.git
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/
# Install PHP Dependencies
su - librenms -c "/opt/librenms/scripts/composer_wrapper.php install --no-dev"
Optimasi MariaDB dan pembuatan database. Password default diset ke: password.
# Optimasi Config MariaDB
cat < /etc/mysql/mariadb.conf.d/50-server.cnf
[server]
[mysqld]
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 127.0.0.1
query_cache_size = 16M
log_error = /var/log/mysql/error.log
innodb_file_per_table=1
lower_case_table_names=0
EOF
systemctl enable mariadb
systemctl restart mariadb
# Buat Database & User
mysql -u root -e "CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -e "CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';"
mysql -u root -e "FLUSH PRIVILEGES;"
Konfigurasi pool PHP khusus LibreNMS dan sinkronisasi waktu ke Asia/Makassar (WITA).
# Copy config default
cp /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/librenms.conf
# Edit config otomatis
sed -i 's/\[www\]/\[librenms\]/' /etc/php/8.2/fpm/pool.d/librenms.conf
sed -i 's/user = www-data/user = librenms/' /etc/php/8.2/fpm/pool.d/librenms.conf
sed -i 's/group = www-data/group = librenms/' /etc/php/8.2/fpm/pool.d/librenms.conf
sed -i 's|listen = /run/php/php8.2-fpm.sock|listen = /run/php-fpm-librenms.sock|' /etc/php/8.2/fpm/pool.d/librenms.conf
# Set Timezone Sistem & PHP ke Asia/Makassar
ln -sf /usr/share/zoneinfo/Asia/Makassar /etc/localtime
echo "Asia/Makassar" > /etc/timezone
sed -i 's|;date.timezone =|date.timezone = Asia/Makassar|' /etc/php/8.2/fpm/php.ini
sed -i 's|;date.timezone =|date.timezone = Asia/Makassar|' /etc/php/8.2/cli/php.ini
Setup Virtual Host untuk akses via IP (tanpa domain).
cat < /etc/nginx/conf.d/librenms.conf
server {
listen 80 default_server;
server_name _;
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;
}
}
EOF
# Restart Services
rm -f /etc/nginx/sites-enabled/default
systemctl restart nginx
systemctl restart php8.2-fpm
systemctl restart mariadb
Mengaktifkan scheduler otomatis agar tidak perlu polling manual.
# Config SNMPD
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
sed -i 's/RANDOMSTRINGGOESHERE/public/' /etc/snmp/snmpd.conf
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
# Setup Cron & Scheduler (Auto Pilot)
cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
systemctl enable cron
systemctl start cron
systemctl enable librenms-scheduler.timer
systemctl start librenms-scheduler.timer
Memastikan permission RRDTool benar agar grafik muncul.
chown -R librenms:librenms /opt/librenms/rrd /opt/librenms/storage
chmod -R 775 /opt/librenms/rrd /opt/librenms/storage
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/storage
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/storage
Buka browser dan akses IP server Anda: http://IP-LXC-ANDA/install