本实例是在云上做的,请开放相关端口 selinux 关闭
在centos系统中执行 
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7- 
x86_64/pgdg-centos10-10-2.noarch.rpm -y  
yum install postgresql10-contrib postgresql10-server -y

初始化数据库
Postgresql安装目录是/usr/pgsql-10,而Postgresql的数据目录是/var/lib/pgsql/版本号/data目 
录在这里,如果在装系统开始分配var空间足够大则可以继续,如果分配var空间不够,我们需要更改数 
据目录,在这里,我们假设var空间足够大。直接开始初始化。
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl start postgresql-10
systemctl enable postgresql-10.service

登录postgresql并设置密码
su - postgres
psql
ALTER USER postgres WITH PASSWORD 'asdqwe123';
创建数据库
CREATE DATABASE zabbix;
创建用户
CREATE USER zabbix CREATEDB LOGIN PASSWORD 'asdqwe123';
将testdb所有权限赋给用户testuser
GRANT ALL ON DATABASE zabbix TO zabbix;
修改监听地址权限
vim  /var/lib/pgsql/10/data/postgresql.conf
listen_addresses = '*'  打开端口5432
vi /var/lib/pgsql/10/data/pg_hba.conf  修改为MD5
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                    md5
host    replication     all             127.0.0.1/32           md5
host    replication     all             ::1/128                md5
host    all             all              0.0.0.0/0             md5  #添加

php安装
安装php源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y - mod_php72w yum-utils php72w-cli php72w-common php72w-gd php72w-mbstring php72w-mysql 
php72-xml php72-fpm php-redis php72w-xml php72w-fpm
systemctl enable php-fpm.service
systemctl start php-fpm

zabbix 安装
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all
yum -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-agent
导入初始架构和数据。
zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
为Zabbix服务器配置数据库
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区。
php_value date.timezone Asia/Shanghai
为Zabbix服务器/代理配置数据库
vi /etc/zabbix/zabbix_server.conf
DBHOST =localhost
数据库名= zabbix
DBUSER = zabbix
DBPASSWORD = asdqwe123
修改文件权限
chown -R root:apache /var/lib/php

httpd配置 vim /etc/httpd/conf/httpd.conf
ServerName x.x.x.x

DocumentRoot "/usr/share/zabbix"

#
# Relax access to content within /var/www.
#
<Directory "/usr/share/zabbix">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/usr/share/zabbix">

启动Zabbix服务器和代理程序进程并使其在系统引导时启动:
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd

打开网址安装
http://x.x.x./setup.php
按照提示进行安装
按照提示修改 vim /etc/php.ini 里面参数 时区设置为PRC
按照提示进行操作完成安装

zabbix 监控 linux 主机   (监控端和被监控端开放10050和10051端口,关闭selinux)
在被监控主机上安装
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all
yum install -y zabbix40-agent.x86_64
cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.old
vim /etc/zabbix/zabbix_agentd.conf   #清空配置文件
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.10.104  # 填写zabbix_server服务端 的 IP
ListenPort=10050
ServerActive=192.168.10.104  # 填写zabbix_server服务端 的 IP
Hostname=aliyun   #监控端主机名
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/*.conf
systemctl  restart zabbix-agent

去网页新建主机 添加模板即可监控