安装lnmp以及zabbix
1,安装nginx本地yum源
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]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
2,安装lnmp
- 安装nginx
yum install nginx -y
systemctl start nginx
systemctl enable nginx
firewall-cmd --permanent --add-service=http --zone=public
firewall-cmd --reload
- 安装mariadb
yum install -y mariadb-server mariadb
systemctl enable mariadb.service
systemctl start mariadb.service
mysql_secure_installation
- 安装php
yum install epel-release -y
或
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 php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysql
- 更改网页类型为nginx
vim /etc/php-fpm.d/www.conf
8 user = nginx
10 group = nginx
- 配置nginx
vim /etc/nginx/conf.d/default.conf
10 index index.php index.html index.htm;
30 location ~ \.php$ {
31 root /usr/share/nginx/html;
32 fastcgi_pass 127.0.0.1:9000;
33 fastcgi_index index.php;
34 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
35 include fastcgi_params;
36 }
- 配置php文件
vim /etc/php.ini
359 expose_php = off
202 short_open_tag = On
368 max_execution_time = 300
378 max_input_time = 300
389 memory_limit = 128M
656 post_max_size = 16M
799 upload_max_filesize = 2M
800 always_populate_raw_post_data = -1
877 date.timezone = Asia/Shanghai
systemctl start php-fpm
systemctl enable php-fpm
systemctl restart nginx
网页验证
http://192.168.199.50/info.php
- 添加主页文档
vim /usr/share/nginx/html/info.php
<?php
$link=mysqli_connect('127.0.0.1','root','123123');
if ($link) echo "true !!!";
else echo "false !!!";
?>
- 启动mysql,并添加数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123';
flush privileges;
- 更改主页文档
vim /usr/share/nginx/html/info.php
<?php
$link=mysqli_connect('127.0.0.1','zabbix','admin123');
if ($link) echo "正确 !!!";
else echo "错误 !!!";
?>
验证页面
http://192.168.199.40/info.php
- 如果发现链接错误,可以参照以下文章进行解决
https://blog.csdn.net/weixin_51614581/article/details/115397284
3,安装zabbix
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.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
grep -n '^' [a-Z] /etc/zabbix/zabbix_server.conf
- 更改zabbix配置文件
vim /etc/zabbix/zabbix_server.conf
38 LogFile=/var/log/zabbix/zabbix_server.log
49 LogFileSize=0
72 PidFile=/var/run/zabbix/zabbix_server.pid
82 SocketDir=/var/run/zabbix
91 DBHost=localhost
100 DBName=zabbix
116 DBUser=zabbix
124 DBPassword=admin123
356 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
473 Timeout=4
516 AlertScriptsPath=/usr/lib/zabbix/alertscripts
527 ExternalScripts=/usr/lib/zabbix/externalscripts
563 LogSlowQueries=3000
vim /etc/httpd/conf.d/zabbix.conf
20 php_value date.timezone Asia/Shanghai
- 赋予权限
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
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
netstat -natp | grep 10051
- 验证网页
http://192.168.199.40/zabbix/setup.php
- 重启服务
systemctl stop php-fpm.service
systemctl stop nginx
systemctl start php-fpm.service
systemctl start nginx
systemctl restart zabbix-server.service
- 这个就需要按照图上的文字来进行解决,手动安装
- 然后就可以登录了
4,在客户机上安装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
'//安装zabbix存储库与agent代理服务'
--
vim /etc/zabbix/zabbix_agentd.conf '//修改zabbix代理配置文件'
Server=192.168.199.50 '//98行,指向监控服务器地址'
ServerActive=192.168.199.50 '//139行,指向监控服务器地址'
Hostname=Zabbix-test '//150行,修改名称'
--
systemctl start zabbix-agent.service && systemctl enable zabbix-agent.service
netstat -ntap |grep 'zabbix'
5,建立主机