文章目录
- Yum安装LNMP架构
- 部署Zabbix
- Zabbix界面操作
- 部署Zabbix代理端
Yum安装LNMP架构
安装Nginx
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
yum clean all
yum list
yum install nginx -y
systemctl enable nginx
systemctl start nginx
netstat -ntap |grep nginx

- 登录页面测试

安装MySQL
yum install mariadb-server mariadb -y
systemctl start mariadb.service
systemctl enable mariadb.service
netstat -ntap |grep 3306

mysql_secure_installation



安装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 php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysql -y
php -v

vim /etc/php-fpm.d/www.conf

vim /etc/nginx/conf.d/default.conf
index index.html index.htm index.php;
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
vim /etc/php.ini
short_open_tag = On
expose_php = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai
systemctl start php-fpm
systemctl enable php-fpm
netstat -ntap |grep 9000

vim /usr/share/nginx/html/info.php
phpinfo();
?>

vim /usr/share/nginx/html/info.php
$link=mysqli_connect('127.0.0.1','root','123456');
if ($link) echo "连接成功";
else echo "连接失败";
?>

部署Zabbix
在数据库中添加zabbix账户
mysql -uroot -p123456
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> drop user ''@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye


vim /usr/share/nginx/html/info.php
$link=mysqli_connect('127.0.0.1','zabbix','123456');
if ($link) echo "连接成功";
else echo "连接失败";
?>

部署Zabbix
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBPassword=123456
cd /usr/share/zabbix
mkdir font
cd font/
vim /usr/share/zabbix/include/defines.inc.php
%s /graphfont/kaiti/g
cp -r /usr/share/zabbix/ /usr/share/nginx/html/
chown -R zabbix:zabbix /etc/zabbix
chown -R zabbix:zabbix /usr/share/nginx/
chown -R zabbix:zabbix /usr/lib/zabbix/
chmod -R 755 /etc/zabbix/web/
chmod -R 777 /var/lib/php/session/
systemctl start zabbix-server.service
systemctl enable zabbix-server.service

Zabbix界面操作
chown zabbix:zabbix /etc/zabbix/web/zabbix.conf.php

- 登录密码是:zabbix


- 如果遇到zabbix agent 不可到达,则需要重新启动zabbix-agent。
部署Zabbix代理端
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum -y install zabbix-agent
Server=192.168.18.169
ServerActive=192.168.18.169
Hostname=Zabbix-test
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
netstat -ntap |grep 10050



- 因为没有安装httpd所以,过一会仪表盘界面就会有httpd报警

- 安装过后,开启httpd服务,报警就会消失。
