[root@localhost ~]# cd /usr/src
[root@localhost src]# ls
debug kernels
[root@localhost src]# ls
debug kernels zabbix-4.0.3.tar.gz
[root@localhost src]# yum -y install net-snmp-devel libevent-devel
.....
Complete!
[root@localhost src]# ls
debug kernels zabbix-4.0.3.tar.gz
[root@localhost src]# tar xf zabbix-4.0.3.tar.gz
[root@localhost src]# id zabbix
id: zabbix: no such user
[root@localhost src]# groupadd -r zabbix
[root@localhost src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
[root@localhost src]# mysql -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost src]# cd /usr/src/zabbix-4.0.3/database/mysql/
[root@localhost mysql]# ls
data.sql images.sql Makefile.am Makefile.in schema.sql
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# cd /usr/src/zabbix-4.0.3/
[root@localhost zabbix-4.0.3]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@localhost zabbix-4.0.3]# make install
[root@localhost ~]# vim /usr/local/etc/zabbix_server.conf
....
DBPassword=zabbix123! //将这一栏的注释去掉并加上密码
[root@localhost zabbix-4.0.3]# zabbix_server //直接启动会遇到报错
zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
[root@localhost zabbix-4.0.3]# find / -name libmysqlclient*
/usr/lib64/mysql/libmysqlclient.so.18
/usr/lib64/mysql/libmysqlclient.so.18.0.0
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/lib/libmysqlclient.a
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/lib/libmysqlclient.so
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/lib/libmysqlclient.so.20
/usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/lib/libmysqlclient.so.20.3.9
[root@localhost zabbix-4.0.3]# ln -s /usr/local/mysql/lib/* /usr/lib //建一个软连接指向so文件。(lamp配置时已经有mysql链接)
[root@localhost zabbix-4.0.3]# ldconfig -v
[root@localhost zabbix-4.0.3]# zabbix_server
[root@localhost zabbix-4.0.3]# zabbix_agentd
[root@localhost zabbix-4.0.3]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@localhost ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@localhost ~]# cd /usr/src/zabbix-4.0.3/
[root@localhost zabbix-4.0.3]# mkdir /usr/local/apache/htdocs/zabbix
[root@localhost zabbix-4.0.3]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@localhost zabbix-4.0.3]# chown -R apache.apache /usr/local/apache/htdocs
[root@localhost zabbix-4.0.3]# vim /etc/httpd24/httpd.conf
//在配置文件的末尾加如下内容
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.example.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@localhost zabbix-4.0.3]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@localhost zabbix-4.0.3]# /usr/local/apache/bin/apachectl -t
Syntax OK
[root@localhost zabbix-4.0.3]#
[root@localhost zabbix-4.0.3]# /usr/local/apache/bin/apachectl stop
[root@localhost zabbix-4.0.3]# /usr/local/apache/bin/apachectl start
[root@localhost zabbix-4.0.3]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@localhost zabbix-4.0.3]# chmod 755 /usr/local/apache/htdocs/zabbix/conf