一键实现基于LNMP架构的zabbix基本安装
发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,#!/bin/bash#简易安装zabbix+LNMP#lnmp(){#关闭防火墙&核心安全功能systemctl stop firewalld.servicesystemctl disable fi
千家信息网最后更新 2024年09月23日一键实现基于LNMP架构的zabbix基本安装
#!/bin/bash#简易安装zabbix+LNMP#lnmp(){#关闭防火墙&核心安全功能systemctl stop firewalld.servicesystemctl disable firewalld.service &> /dev/nullsetenforce 0sed -i "7cSELINUX=disabled" /etc/sysconfig/selinux#yum安装nginxwget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm#手动创建nginx安装源(centos可以根据不同系统进行替换,后面的版本同样)echo "[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/\$basearch/gpgcheck=0enabled=1" > /etc/yum.repos.d/nginx.repoyum install nginx -y#启动nginxsystemctl start nginxsystemctl enable nginx#安装mysql 5.7并启动yum install -y mariadb-server mariadb expectsystemctl enable mariadb.servicesystemctl start mariadb.service#设定数据库初始密码/usr/bin/expect <0;i++));dorpm -q php72w-cli &> /dev/nullif [ $? -ne 0 ];then yum install -y php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysqlelse breakfidone#修改fpm模块使其支持nginxsed -i -e "8cuser = nginx" -e "10cgroup = nginx" /etc/php-fpm.d/www.conf#更改nginx配置文件使其能识别php动态文件sed -i "10s/index.html/index.html index.php/" /etc/nginx/conf.d/default.confsed -i -e "30,36s/#//" -e "31s/html/\/usr\/share\/nginx\/html/" -e "34s/\/scripts/\$document_root/" /etc/nginx/conf.d/default.conf#配置PHPsed -i -e "359s/On/Off/" -e "202s/Off/On/" /etc/php.ini#重启服务systemctl start php-fpmsystemctl enable php-fpmsystemctl restart nginx}#检测LNMP架构是否已经安装完毕systemctl restart nginx &> /dev/nullservice mysqld restart &> /dev/nullsystemctl restart mariadb &> /dev/nullnetstat -atnp | egrep '(nginx|3306)' &> /dev/nullif [ $? -ne 0 ];then lnmpfi#配置PHP以适应zabbixsed -i -e "368s/30/300/" -e "378s/60/300/" -e "656s/8/16/" -e "799aalways_populate_raw_post_data = -1" -e "877cdate.timezone = Asia/Shanghai" /etc/php.inisystemctl restart php-fpm#建立zabbix数据库和管理用户mysql -uroot -p123123 -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;"mysql -uroot -p123123 -e "GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'zhy94666';"mysql -uroot -p123123 -e "flush privileges;"#解决本地无法登录问题mysql -uroot -p123123 -e "drop user ''@localhost;"mysql -uroot -p123123 -e "drop user ''@localhost.localdomain;"mysql -uroot -p123123 -e "flush privileges" #安装zabbixrpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpmfor ((k=1;k>0;k++));do rpm -q zabbix-agent &> /dev/null if [ $? -ne 0 ];then yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y else break fidone#生成数据库文件zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzhy94666 zabbix#修改zabbix服务端配置文件sed -i -e "91s/# //" -e "125cDBPassword=zhy94666" /etc/zabbix/zabbix_server.conf#提权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/#启动zabbixsystemctl start zabbix-server.servicesystemctl enable zabbix-server.servicesystemctl start zabbix-agent.servicesystemctl enable zabbix-agent.service#所有服务重启systemctl restart php-fpm nginx mariadb zabbix-server zabbix-agent#检查服务是否均启动test=`netstat -atnp | egrep '(nginx|3306|10051|10050)' | grep -v "TIME_WAIT" | wc -l`if [ $test -ge 5 ];then echo "zabbix服务端设置完成"fidizhi=`ifconfig ens33 | awk 'NR==2{print $2}'`echo "请使用浏览器登陆${dizhi}/zabbix/进行安装默认登陆用户名为:Admin默认登陆密码为:zabbix"
服务
文件
配置
数据
数据库
登陆
密码
用户
架构
不同
安全
功能
动态
手动
核心
模块
浏览器
版本
简易
系统
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全年主题
ado数据库访问技术博客园
苏州爱搭网络技术有限公司
名词解释数据库应用系统
河南北斗校时服务器云主机
福州网络安全宣传周
网络安全风险不容忽视
网络安全局总工程师
数据库同步工具免费下载
无线呼叫服务器
常见结构化数据库
软件开发有几年发展前景
甘肃网络安全等级标准
服务器流量测试工具
新一代网络技术研究院
软件开发用手机
青岛crm软件开发服务费
智慧城管软件开发电话
广州五叶草互联网科技
网站网络安全工作考核指标
网络编程服务器读取客户端信息
不连接老头环的服务器可以联机吗
网络安全密钥水杨酸
广州圆心网络技术怎样
r2服务器管理系统
深圳中澳网络技术有限公司
链接服务器 别名
滴滴出行的软件开发流程
数据库三个表查询
crm服务器部署