Centos7中一键安装zabbix
作者:邓聪聪
#!/bin/sh
log=/root/install.log
exec 2>>$log
#关闭SELINUX,防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce
echo "enforce `getenforce`"
#lnmp搭建
###写入nginx.repo源
echo "Insatlling nginx,please wait!"
echo '[nginx]
name=nginx.repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=
enabled='>>/etc/yum.repos.d/nginx.repo
#安装nginx
rm -f /var/run/yum.pid
yum -y install nginx &> /dev/null
if [ `echo $?` -eq ]
then
echo "nginx install successful!"
else
echo "nginx install failed.please check it!"
exit
fi
service nginx start &> /dev/null
if [ `echo $?` -eq ]
then
echo -e "nginx is running.\n"
else
echo "nginx start failed.please check it!"
exit
fi ###安装mariadb(mysql)
###安装php
#查看php的yum源版本
if [ `yum list | grep ^php|head -n |awk -F"." '{print $3}'` -ge ]
then
echo "Your php-version support zabbix 3.0,installing now!"
else
echo "Your php-version can't support zabbix 3.0!Installing failed!"
exit
fi
echo "Installing mysql and php,please wait!"
for i in mysql mariadb-server php php-mysql php-fpm
do
yum -y install $i &> /dev/null
if [ `echo $?` -eq ]
then
echo "$i install successful!"
else
yum -y install $i &> /dev/null
fi
done
for j in mariadb.service php-fpm
do
systemctl start $j &> /dev/null
if [ `echo $?` -eq ]
then
echo "$j is running!"
else
echo "$j start failed!please check it!"
exit
fi
systemctl enable $j &> /dev/null
done #修改php配置使其适合zabbix
cp /etc/php.ini /etc/php.ini.backup
sed -i 's#;date.timezone =#date.timezone = PRC#' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/' /etc/php.ini
sed -i 's/max_input_time = 60/max_input_time = 300/' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 16M/' /etc/php.ini #修改php-fpm
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.backup
sed -i 's/user = apache/user = nginx/' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/group = nginx/' /etc/php-fpm.d/www.conf echo '<?php
phpinfo();
?>' >>/usr/share/nginx/html/index.php mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.backup
echo '
server {
listen ;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}'>>/etc/nginx/conf.d/phpinfo.conf
systemctl restart nginx php-fpm #测试nginx代理和php页面文件
echo -e "\nTesting http://localhost (The state of nginx) "
echo "Testing http://localhost/index.php (The state of php)"
if [ "`curl -s localhost | grep Welcome | tail -n 1| awk -F"<h1>" '{print $2}'| awk -F"</h1>" '{print $1}'`" = "Welcome to nginx!" ]
then
echo "The web of nginx is normal!"
else
echo "ERROR! The web if nginx isn't normal!"
fi if [ "`curl -s localhost/index.php | grep "PHP Version" | tail -n 1 |awk -F">" '{print $3}'| awk -F"<" '{print $1}'`" = "PHP Version " ]
then
echo "The web of php is normal!"
else
echo "ERROR! The web of php isn't normal!"
fi ##安装zabbix
echo -e "\nInstalling ZABBIX,please wait."
za_install(){
rpm -i https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm &> /dev/null
yum -y install $k &> /dev/null
} for k in zabbix-server-mysql zabbix-web-mysql zabbix-agent
do
za_install
if [ `echo $?` -eq ]
then
echo "$k install successful!"
else
za_install
fi
done echo -e "\nThe following zabbix application had installed."
rpm -qa|grep zabbix
#创建zabbix数据库 echo -e '\nCreating the mysql database.'
mysql<<EOF
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
EOF zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix ##修改zabbix配置
sed -i 's/^# DBHost=localhost/DBHost=localhost/' /etc/zabbix/zabbix_server.conf
sed -i 's/^# DBPassword=/DBPassword=zabbix/' /etc/zabbix/zabbix_server.conf ###为zabbix创建一个新的nginx配置文件
echo '
server {
listen ;
server_name localhost; root /usr/share/zabbix; location / {
root /usr/share/zabbix;
index index.php;
} error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}'>/etc/nginx/conf.d/phpinfo.conf chown -R nginx:nginx /etc/zabbix/web
chown -R nginx:nginx /var/lib/php/session
systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm &> /dev/null echo -e 安装完成。请登陆"\e[1;31m localhost/setup.php \e[0m"页面进行zabbix安装设置。
echo -e The install is successful,please login "\e[1;31m localhost/setup.php \e[0m" to configure your web of zabbix(user=Admin pwd=zabbix)。
Centos7中一键安装zabbix的更多相关文章
- RabbitMQ3.9.7在CentOS7中的安装搭建
1.概述 RabbitMQ 是目前很流行的消息中间件之一,可靠性非常好,能简单的实现高可用.负载均衡. 今天我们先来聊一下 RabbitMQ 3.9.7 版本在 CentOS7 中的安装. 2.安装R ...
- docker 一键安装zabbix server、zabbix agent
基本原理.须知:1.zabbix 分为zabbix server和zabbix agent,其中zabbix server需要web环境,并且其数据存储在独立的数据库中:2.docker是一种容器服务 ...
- Centos6.5中 一键安装LNMP 安装Yii2.0 手工配置
1.一键安装LNMP cd /usr wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz tar zxf lnmp1.-full.tar.gz ...
- Centos7中离线安装DockerCE最新版
一.简述 离线在Centos7中部署DockerCE. 二.步骤 (1)在有外网的计算A上执行: 1.配置安装源存放路径 mkdir -p /root/docker-ce-local &&am ...
- 一键安装 zabbix 3.0 版本 脚本
原文地址: http://blog.csdn.net/u012449196/article/details/53859068 本文修改了原文中的部分错误,此脚本适用于zabbix 2.0 或 3.0 ...
- 一键安装 zabbix 2.0 版本 脚本
原文地址: http://blog.csdn.net/u012449196/article/details/53859068 本文修改了原文中的部分错误,此脚本适用于zabbix 2.0 版本,以版本 ...
- 分布式搜索引擎Elasticsearch在CentOS7中的安装
1. 概述 随着企业业务量的不断增大,业务数据随之增加,传统的基于关系型数据库的搜索已经不能满足需要. 在关系型数据库中搜索,只能支持简单的关键字搜索,做不到分词和统计的功能,而且当单表数据量到达上百 ...
- CentOS7中编译安装redis5.0
1. 环境介绍 CentOS7 (未安装Development Tools) 2. 下载Redis5.0-rc3 wget -O redis-5.0-rc3.tar.gz https://github ...
- Python魔术世界 1 如何使用Visual Studio在WIN10中一键安装Python3入门编程环境并测试Django
本文通过VS安装Python和Django的环境,创建了一个Web程序,前后5分钟的操作,让你快速入门Python的编程世界,各种Python和Django的概念会在实战中给你娓娓道来. Django ...
随机推荐
- android H5支付 网络环境未能通过安全验证,请稍后再试
android做混合开发微信H5支付时碰到的一个问题. 解决办法:把所使用的WebView中重新如下方法即可 webView.setWebViewClient(new WebViewClient() ...
- Spring Boot2.0使用Spring Security
一.Spring Secutity简介 Spring 是一个非常流行和成功的 Java 应用开发框架.Spring Security 基于 Spring 框架,提供了一套 Web 应用安全性 ...
- RabbitMQ学习笔记一:本地Windows环境安装RabbitMQ Server
一:安装RabbitMQ需要先安装Erlang语言开发包,百度网盘地址:http://pan.baidu.com/s/1jH8S2u6.直接下载地址:http://erlang.org/downloa ...
- 《Effective C++》继承与面对对象设计:条款32-条款40
条款32:确定你的public继承塑模出is-a关系 public继承意味着is-a.适用于base class身上的每一个函数也一定适用于derived class. 条款33:避免遮掩继承而来的名 ...
- Express使用art-template模板引擎
第一步:安装 npm install --save art-template npm install --save express-art-template 第二步:指定.html使用的解析引擎(官方 ...
- Java多线程-线程池ThreadPoolExecutor构造方法和规则
为什么用线程池 原文地址 http://blog.csdn.net/qq_25806863/article/details/71126867 有时候,系统需要处理非常多的执行时间很短的请求,如果每一个 ...
- Spring MVC 使用介绍(十一)—— 跨域与静态资源访问
一.跨域 服务端须在响应中添加相应响应头,从而允许跨域,具体可通过 public class CorsFilter extends OncePerRequestFilter { @Override p ...
- Flask 模板系统
模板 基本数据类型 可以执行python语法,如:dict.get(), list['xx'] 比django 更加亲近于 python 传入函数 - django,自动执行 - flask,不自动执 ...
- 【Spring】Spring Data JPA
原始JDBC操作数据库 传统JDBC方式实现数据库操作 package com.imooc.util; import java.io.InputStream; import java.sql.*; i ...
- A.01.11—模块的输出—输出复用和可配
对于输入来说,高边输入与低边输入可配,那对于输出来说,它有哪些可配的情况呢. 下图中展示了2种常见的类型. 第一种为同一驱动芯片内部的情况.对于OPL与ODL,即PWM低端输出和固态的低端输出,它们是 ...