I also noticed this issue and decided to install zabbix myself. I figured it was a good learning exercise.
If you are open to that option, these steps worked for me (please don't ask for support if anything goes wrong as I am not an IT professional). These instructions are lengthy as it involve many moving parts but they should help you get a zabbix6 installed in truenas with apache, PHP7.4 Mysql and IPMI.
Assumptions
You know how to create jails.
You feel comfortable with the command line.
You know how to create, delete and modify config files from the command line.
Jail name: Zabbix
Jail IP: 10.0.0.24
Mysql root password: "zabbix-mysql-root" (PLEASE CHANGE THIS TO SOMETHING SECURE).
Mysql zabbix user password: "zabbixDBpass" (PLEASE CHANGE THIS TO SOMETHING SECURE).
Instructions will not discuss HTTPS redirect or SSL certificates (I use HA proxy on PFsense for this)
1. Create a jail.
2. SSH into truenas.
3. Get into the zabbix jail
iocage console zabbix
Install Zabbix
4. Install packages
pkg update && pkg upgrade
pkg install -y libevent libpthread-stubs zlib-ng openipmi fping curl openssl wget
pkg install -y apache24
pkg install -y mysql80-server
5. Install zabbix server from ports as this is the only way of getting compatibility with IPMI
portsnap fetch extract
portsnap fetch update
cd /usr/ports/net-mgmt/zabbix6-server/
make config
make install clean
A new window will appear, enable all the options you want (noticed how i selected IPMI
View attachment 56279
6. Install zabbix frontentd and agent
pkg install -y zabbix6-frontend-php74
pkg install -y zabbix6-agent
7. Install php and all required extensions
pkg install -y mod_php74 php74-gd php74-bcmath php74-ctype php74-xml php74-simplexml php74-xmlreader php74-xmlwriter php74-session php74-sockets php74-mbstring php74-gettext php74-ldap php74-openssl php74-mysqli nmap ipmitool nut
Setup apache (webserver)
8. Enable apache
sysrc apache24_enable=yes
9.Open the file
/usr/local/etc/apache24/httpd.conf
uncomment the line "ServerName", indicate the IP of the jail (10.0.0.24 in this example)save and exit. The line should look similar to
ServerName 10.0.0.24:80
10.Start the webserver
service apache24 start
11. verify that the webserver is running by opening a browser and going to
http://10.0.0.24. This should open the default apache webpage.
Setup MySQL
12. Enable and start the mysql service
sysrc mysql_enable=yes
service mysql-server start
13.Enable the security features of mysql
mysql_secure_installation
- The system will ask if we want to "validate password component". Click any key for NO
- The system will ask for a new password for root. Type "zabbix-mysql-root"
- the system will ask if we want to "remove anonymous users". Type "Y".
- The system will ask if we want to "Dissallow root login remotely". Type "Y".
- The system will ask if we want to "Remove test database and access to it". Type "Y".
- The system will ask if we want to reload priviledge table now". Type "Y".
14. Enter the Mysql terminal
mysql -uroot -pzabbix-mysql-root
15. enter the following commands
create database zabbix character set utf8mb4 collate utf8mb4_bin;
SHOW DATABASES;
create USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'zabbixDBpass';
grant all privileges on zabbix.* to 'zabbix'@'localhost';
FLUSH PRIVILEGES;
quit;
16. Install the zabbiz database
cd /usr/local/share/zabbix6/server/database
mysql -uzabbix -pzabbixDBpass zabbix < mysql/schema.sql
mysql -uzabbix -pzabbixDBpass zabbix < mysql/images.sql
mysql -uzabbix -pzabbixDBpass zabbix < mysql/data.sql
Setup Zabbix Server
17. open the file
/usr/local/etc/zabbix6/zabbix_server.conf
, Uncomment and change the following parameters:
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixDBpass
StartIPMIPollers=3
18. create a log folder
mkdir /var/log/zabbix/
chown zabbix:zabbix /var/log/zabbix/
19. enable and start the zabbix server service
sysrc zabbix_server_enable=yes
service zabbix_server start
Setup PHP
20. Create the PHP config file
cd /usr/local/etc
cp php.ini-production php.ini
21. Open the config file
/usr/local/etc/php.ini
; uncomment the line "date.timezone" and indicate your timezone. For eastern US it should be
date.timezone= America/New_York
22. Enable and start the php_fpm service
sysrc php_fpm_enable=yes
service php-fpm start
23. Create the apache php module config file
touch /usr/local/etc/apache24/modules.d/001_mod-php.conf
24. open the apache php module config file and paste the following text
Code:
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
25. Test if apache configuration is valid
apachectl configtest
26. Restart apache
service apache24 restart
27. create a test file for php
touch /usr/local/www/apache24/data/info.php
28. open the php test file and add the following content
Code:
<?php
phpinfo(); //display all info
?>
29. Create an apache virtual host for the php test page
touch /usr/local/etc/apache24/Includes/test.conf
30. add the following content to the apache virtual host for the php test page
Code:
<VirtualHost *:80>
DocumentRoot "/usr/local/www/apache24/data"
ServerName 10.0.0.24
<Directory "/usr/local/www/apache24/data">
Require all granted
AllowOverride All
Options Indexes FollowSymLinks
Satisfy Any
<IfModule mod_php7.c>
php_value max_execution_time 300
php_value memory_limit 512M
php_value post_max_size 128M
php_value upload_max_filesize 128M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
</IfModule>
</Directory>
DirectoryIndex index.php index.html
</VirtualHost>
31. Restart apache
service apache24 restart
32. Test by opening a browser and going to
http://10.0.0.24/info.php. This should open a webpage with all the specs for the php installation.
33. If everythign went ok, delete the php test files.
rm /usr/local/etc/apache24/Includes/test.conf
rm /usr/local/www/apache24/data/info.php
Setup Zabbix frontend
34. Create an apache virtual host for the zabbix frontend page
touch /usr/local/etc/apache24/Includes/zabbix.conf
35. add the following content to the apache virtual host for the zabbix frontend page
Code:
<VirtualHost *:80>
ServerName 10.0.0.24
ServerAdmin lrossi@levelupec.com
DocumentRoot "/usr/local/www/zabbix6"
<Directory "/usr/local/www/zabbix6">
Require all granted
AllowOverride All
Options Indexes FollowSymLinks
<IfModule mod_php7.c>
php_value max_execution_time 300
php_value memory_limit 512M
php_value post_max_size 128M
php_value upload_max_filesize 128M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
</IfModule>
</Directory>
DirectoryIndex index.php index.html
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000"
</IfModule>
</VirtualHost>
36. Restart apache
service apache24 restart
37. Test by opening a browser and going to
http://10.0.0.24/zabbix. This should open the zabbix initial setup wizard. Note, after the wizard has been completed, we can access this zabbix server just by indicating its IP address.
Setup Zabbix agent
38. Open the zabbix agent configuration file
/usr/local/etc/zabbix6/zabbix_agentd.conf
and change the LogFile line to
LogFile=/var/log/zabbix/zabbix_agent.log
39. Enable and start the zabbix agent service
sysrc zabbix_agentd_enable=yes
service zabbix_agentd start
Troubleshooting
Problem #1: At least for me, when i was doing the initial setup, zabbix indicated that it couldn't create a configuration file and had a ling to download one.
Solution #1: Download the file to your local computer, open it in notepad and copy its content.
SSH into the jail, create a new config file
touch /usr/local/www/zabbix6/conf/zabbix.conf.php
and paste the contents of the zabbix config file that we downloaded earlier.
Go back tot he web interface and try again. This should solve the problem
Problem #2: Some times duting the initial setup zabbix will indicate that it cannot connect to the database.
Solution #2: SSH into the zabbix jail
enter the mysql terminal
mysql -uroot -p
then issue the following commands
ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'zabbixDBpass';
FLUSH PRIVILEGES;
quit;
and restart the mysql service
service mysql-server restart
In the end, i realized that Zabbix was not the right solution for my envirmoment but I hope that these instructions are helpful to somebody else down the line.