Zabbix installation and setup

Ubuntu 16.04 LTS (xenial):

$ wget
$ dpkg -i zabbix-release_3.0-1+xenial_all.deb
$ apt-get update
$ sudo apt-get install zabbix-agent zabbix-server-mysql zabbix-frontend-php snmpd php5.6-mysql php5.6-curl
$ sudo nano /etc/php/5.6/apache2/php.ini

; Defines the default timezone used by the date functions
date.timezone = America/Sao_Paulo

$ sudo /etc/init.d/apache2 restart

php info date

Determine what port zabbix listening to. Should be either or all 10050 and 10051. One for agent another for server.
$ sudo netstat -tlnp | grep zabbix
zabbix port listening


Default Username: Admin
Default Password: zabbix

Error Solution: The frontend does not match Zabbix database
zabbix database installation error

You should first populate the database with the sql file provided in /usr/share/doc/zabbix-server-mysql/create.sql

Depending on the size allowed in phpmyadmin its best to import thru the command line. Also this allows to edit the file if any errors (possible 1709)
$ mysql -u root -p zabbix < create.sql

Configure port
If you have the incorrect port set you will get this error
Zabbix server is running
To view the zabbix port (you may need to start zabbix)
$ sudo /etc/init.d/zabbix-agent restart
$ sudo netstat -tlnp | grep zabbix
To change web port
$ sudo nano /etc/zabbix/web/zabbix.conf.php

$ZBX_SERVER      = '';
$ZBX_SERVER_PORT = '10050';

To change agent port
$ sudo nano /etc/zabbix/zabbix_agentd.conf

### Option: ListenPort
#	Agent will listen on this port for connections from the server.
# Mandatory: no
# Range: 1024-32767
# Default:

If you want reinstall zabbix. To get the installation screen
delete /etc/zabbix/web/zabbix.conf.php
go to http://localhost/zabbix/setup.php

# comment out the line 'mibs'
$ sudo nano /etc/snmp/snmp.conf

# As the snmp packages come without MIB files due to license reasons, loading
# of MIBs is disabled by default. If you added the MIBs you can reenable
# loading them by commenting out the following line.
#mibs :

# error log location

possible errors

server error:
[Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123'
$ sudo nano file:/etc/zabbix/zabbix_server.conf

### Option: DBPassword
#	Database password. Ignored for SQLite.
#	Comment this line if no password is used.
# Mandatory: no
# Default:

agent error:
$ tail -f zabbix_agentd.log
failed to accept an incoming connection: connection from "" rejected, allowed hosts: ""
zabbix_agentd.conf 'Server=...' need to match /etc/zabbix/web/zabbix.conf.php '$ZBX_SERVER'
$ sudo nano /etc/zabbix/zabbix_agentd.conf


$ sudo /etc/init.d/zabbix-agent restart