Thanks to this post by thedutchlab.com and the official docs.
Install required packages
- Apache:
apt-get install libapache2-mod-php7.0 php
- Install the missing php packages required on Ubuntu 16/php7:
apt-get install php7.0-mbstring
apt-get install php7.0-bcmath
apt-get install php-xmlwriter
- MySQL: See previous post
apt-get install php-mysql
- Zabbix
apt-get install zabbix-server-mysql zabbix-frontend-php
apt-get install libapache2-mod-php7.0 php
apt-get install php7.0-mbstring
apt-get install php7.0-bcmath
apt-get install php-xmlwriter
apt-get install php-mysql
apt-get install zabbix-server-mysql zabbix-frontend-php
Create the Database
- Refer to my previous post about creating MySQL databases.
- Change to the sql directory and unzip the files:
cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz
- Install them:
mysql -u zabbix -p zabbix < schema.sql
It will prompt for password then take a while
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
- Edit the zabbix config (see below)
cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz
mysql -u zabbix -p zabbix < schema.sql
It will prompt for password then take a while
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
Modify PHP
vi/etc/php/7.0/apache/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = "Europe/London"
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = "Europe/London"Modify Zabix Config
- Edit the Zabbix Config to add the DB User/Pasword:
vi /etc/zabbix/zabbix_server.conf
Set DBPassword
- Edit the Zabbix php configuration:
cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
/usr/share/zabbix/conf/zabbix.conf.php
vi /etc/zabbix/zabbix.conf.php
Set the database PASSWORD
- Copy the zabbix apache conf to apache.available:
cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf
cd /etc/apache2/conf-available/
a2enconf zabbix.conf
a2enmod alias
service apache2 restart
- Edit the Zabbix configuration:
vi /etc/default/zabbix-server
START=yes
- Edit the Zabbix Config to add the DB User/Pasword:
vi /etc/zabbix/zabbix_server.conf
Set DBPassword - Edit the Zabbix php configuration:
cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
/usr/share/zabbix/conf/zabbix.conf.php
vi /etc/zabbix/zabbix.conf.php
Set the database PASSWORD - Copy the zabbix apache conf to apache.available:
cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf-available/zabbix.conf
cd /etc/apache2/conf-available/
a2enconf zabbix.conf
a2enmod alias
service apache2 restart - Edit the Zabbix configuration:
vi /etc/default/zabbix-server
START=yes
Modify the php file for php7
You'll get an error about always_populate_raw_post_data but this is deprecated below php 7
- vi /usr/share/zabbix/include/classes/setup/CFrontendSetup.php
- Find the line: if (version_compare(PHP_VERSION, '5.6'
- Change to: if (version_compare(PHP_VERSION, '7.1'
Re-Start the Services
sudo service zabbix-server restart
sudo service apache2 restart
sudo service apache2 restart
Install Agent on Minions
- apt-get update
apt-get install zabbix-agent
- vi /etc/zabbix/zabbix_agentd.conf
Amend Server=localhost replacing the IP address of your Zabbix install
- /etc/init.d/zabbix-agent start
- apt-get update
apt-get install zabbix-agent - vi /etc/zabbix/zabbix_agentd.conf
Amend Server=localhost replacing the IP address of your Zabbix install - /etc/init.d/zabbix-agent start
Load the web Interface
wget http://localhost/zabbix
http://xx.xx.xx.xx/zabbix
Default username/password: Admin/zabbix
http://xx.xx.xx.xx/zabbix
Default username/password: Admin/zabbix
Troubleshooting
Test PHP
- vi /var/www/html/test.php
<?php
phpinfo();
?>
- http://<host IP>/test.php
Should Return: PHP Version 7.0.8-0ubuntu0.16.04.3... etc
- Try it in the zaabix directory:
cp /var/www/html/test.php /usr/share/zabbix/test.php
- Turn on display errors:
vi /etc/php/7.0/cli/php.ini
display_errors on
- Restart apache
- vi /var/www/html/test.php
<?php
phpinfo();
?> - http://<host IP>/test.php
Should Return: PHP Version 7.0.8-0ubuntu0.16.04.3... etc - Try it in the zaabix directory:
cp /var/www/html/test.php /usr/share/zabbix/test.php - Turn on display errors:
vi /etc/php/7.0/cli/php.ini
display_errors on - Restart apache
Output PHP errors:
Wrap your error-ing script in a try catch:
try{
// existing code
} catch(Error $e) {
echo $e->getMessage();
}
Also can try outputting error log to file:
error_log = /var/log/php_errors.log
touch the file:
touch /var/log/php_errors.log
chown www-data: /var/log/php_errors.log
chmod +rw /var/log/php_errors.log
tail /var/log/php_errors.log
try{
// existing code
} catch(Error $e) {
echo $e->getMessage();
}
Also can try outputting error log to file:
error_log = /var/log/php_errors.log
touch /var/log/php_errors.log
chown www-data: /var/log/php_errors.log
chmod +rw /var/log/php_errors.log
tail /var/log/php_errors.log
Zabbix Server Log
vi /var/log/zabbix-server/zabbix_server.log
Also Check
- Apache errors: /var/log/apache2/error.log
- Error 500: Probably a problem with apache-php
- Error 404: Re-check the installation steps, you have missed something as the web server/site doesn't exist.
- If it's giving php errors like: Minimum required size of PHP post is 16M then check the php.ini file: if it has any syntax errors it will revert to defaults:
cp /usr/lib/php/7.0/php.ini-production vi/etc/php/7.0/apache/php.ini
cp /usr/lib/php/7.0/php.ini-production vi/etc/php/7.0/apache/php.ini
No comments:
Post a Comment