One-click implementation of basic installation of zabbix based on LAMP architecture
#! / bin/bash# easy installation zabbix+LAMP#lamp () {# disable firewall & core security function systemctl stop firewalld.servicesystemctl disable firewalld.service & > / dev/nullsetenforce 0sed-I "7cSELINUX=disabled" / etc/sysconfig/selinuxyum install-y\ httpd\ mariadb-server mariadb\ php\ php-mysql\ php-gd\ libjpeg*\ php-ldap\ php-odbc\ php-pear\ php-xml\ php-mhash\ expect# modify httpd's configuration file sed-I -e "95aServerName www.kgc.com"-e "/ DirectoryIndex/s/index.html/index.html index.php/" / etc/httpd/conf/httpd.conf# modifies PHP's time zone sed-I "878cdate.timezone = PRC" / etc/php.ini# database & httpd starts systemctl start httpd.servicesystemctl enable httpd.servicesystemctl start mariadb.servicesystemctl enable mariadb.service# to set the database initial password / usr/bin/expect / dev/nullsystemctl restart mariadb & > / dev/nullnetstat -atnp | egrep'(httpd | 3306)'& > / dev/nullif [$?-ne 0] Then lampfi# establishes zabbix database and manages user 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 "echo" begins to prepare to install zabbix "sleep" install PHP corresponding tool yum install php-bcmath php-mbstring-y # to generate zabbix corresponding to yum source rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm# install zabbix (network is not good, it is difficult to install zabbix) for ((item1 / ivh)); dorpm-Q zabbix-web-mysql & > / dev/nullif [$?-ne 0] Then yum install zabbix-server-mysql zabbix-web-mysql-yelse breakfidone# solves the local login problem mysql-uroot-p123123-e "drop user'@ localhost;" mysql-uroot-p123123-e "drop user'@ localhost.localdomain" "mysql- uroot-p123123-e" flush privileges "# generate database file zcat / usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql- uzabbix-pzhy94666 zabbix# modify zabbix server configuration file sed-I" 125cDBPassword=zhy94666 "/ etc/zabbix/zabbix_server.conf# modify time zone sed-I" 20cphp_value date.timezone Asia/Shanghai "/ etc/httpd/conf.d/zabbix.confsystemctl enable zabbix-serversystemctl start zabbix -serverservice httpd restartnetstat-anpt | grep zabbix & > / dev/nullif [$?-eq 0] Then echo "zabbix server setup completed" fidizhi= `ifconfig ens33 | awk 'NR==2 {print $2}' `echo "Please use the browser to log in to ${dizhi} / zabbix/ to install the default login user name is: Admin default login password is: zabbix"