作者:邓聪聪

#!/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的更多相关文章

  1. RabbitMQ3.9.7在CentOS7中的安装搭建

    1.概述 RabbitMQ 是目前很流行的消息中间件之一,可靠性非常好,能简单的实现高可用.负载均衡. 今天我们先来聊一下 RabbitMQ 3.9.7 版本在 CentOS7 中的安装. 2.安装R ...

  2. docker 一键安装zabbix server、zabbix agent

    基本原理.须知:1.zabbix 分为zabbix server和zabbix agent,其中zabbix server需要web环境,并且其数据存储在独立的数据库中:2.docker是一种容器服务 ...

  3. 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 ...

  4. Centos7中离线安装DockerCE最新版

    一.简述 离线在Centos7中部署DockerCE. 二.步骤 (1)在有外网的计算A上执行: 1.配置安装源存放路径 mkdir -p /root/docker-ce-local &&am ...

  5. 一键安装 zabbix 3.0 版本 脚本

    原文地址: http://blog.csdn.net/u012449196/article/details/53859068 本文修改了原文中的部分错误,此脚本适用于zabbix 2.0 或 3.0 ...

  6. 一键安装 zabbix 2.0 版本 脚本

    原文地址: http://blog.csdn.net/u012449196/article/details/53859068 本文修改了原文中的部分错误,此脚本适用于zabbix 2.0 版本,以版本 ...

  7. 分布式搜索引擎Elasticsearch在CentOS7中的安装

    1. 概述 随着企业业务量的不断增大,业务数据随之增加,传统的基于关系型数据库的搜索已经不能满足需要. 在关系型数据库中搜索,只能支持简单的关键字搜索,做不到分词和统计的功能,而且当单表数据量到达上百 ...

  8. CentOS7中编译安装redis5.0

    1. 环境介绍 CentOS7 (未安装Development Tools) 2. 下载Redis5.0-rc3 wget -O redis-5.0-rc3.tar.gz https://github ...

  9. Python魔术世界 1 如何使用Visual Studio在WIN10中一键安装Python3入门编程环境并测试Django

    本文通过VS安装Python和Django的环境,创建了一个Web程序,前后5分钟的操作,让你快速入门Python的编程世界,各种Python和Django的概念会在实战中给你娓娓道来. Django ...

随机推荐

  1. spring中基于注解使用AOP

    本文内容:spring中如何使用注解实现面向切面编程,以及如何使用自定义注解. 一个场景 比如用户登录,每个请求发起之前都会判断用户是否登录,如果每个请求都去判断一次,那就重复地做了很多事情,只要是有 ...

  2. 固件远程更新之STARTUPE2原语(fpga控制flash)

    作者:九章子 来源:CSDN 原文:https://blog.csdn.net/jiuzhangzi/article/details/79471365 有的项目需要远程更新固件,更新完成后断电.重启即 ...

  3. webpack4配置详解之新手上路初探

    前言 经常会有群友问起webpack.react.redux.甚至create-react-app配置等等方面的问题,有些是我也不懂的,慢慢从大家的相互交流中,也学到了不少. ​ 今天就尝试着一起来聊 ...

  4. 【Swift 4.2】uuid 取 hashCode(与 Java/Go/Kotlin 一致)

    extension String { func hashCode() -> Int32 { let components = self.split(separator: "-" ...

  5. 1 Introduction

    1. Introduction 1.1. License Flowable is distributed under the Apache V2 license. 1.2. Download http ...

  6. Git—分支管理

    Git—分支管理 分支学习:branch称为分支,默认仅有一个名为master的分支.一般开发新功能流程为:开发新功能时会在分支dev上进行,开发完毕后再合并到master分支. branch相关常用 ...

  7. C语言之控制语言:分支和跳转

    if语句 #include<stdio.h> int main(void) { const int FREEZING = 0; float temperature; int cold_da ...

  8. Kubernetes — Job与CronJob

    有一类作业显然不满足这样的条件,这就是“离线业务”,或者叫作 Batch Job(计算业务). 这 种业务在计算完成后就直接退出了,而此时如果你依然用 Deployment 来管理这种业务的话,就会 ...

  9. 【php】记录一次生产环境bug的调试

    参考链接: [php调试利器 -- xdebug]https://www.cnblogs.com/anyeshe/p/5746404.html [PHP 后端调试输出方法(笨办法)]https://b ...

  10. UIAutomator简介

    简介 Android 4.3发布的时候包含了一种新的测试工具–uiautomator,uiautomator是用来做UI测试的.也就是普通的手工测试,点击每个控件元素 看看输出的结果是否符合预期.比如 ...