一、安装centos 7.9版本
二、通过批处理安装zabbix 6.4
把下列代码复制到TXT文本中,改后缀为.sh 运行脚本(示例bash zabbix_v6.4.sh)
#!/usr/bin/env bash
# ILNMP(Linux Nginx MySQL Zabbix Grafana)Unattended PHP Zabbix Development Environment Tool
# Version: v0.9.1
# Author: Renwole.com
# Last update 13/02/2021
# Script support highly customized
# Thank you for using Renwole script
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
printf "
#######################################################
# Zabbix Install Tool for CentOS/RedHat 7+ #
# For more please visit https://renwole.com #
#######################################################
"
echo
# php
php_74_version="7.4.19"
php_80_version="8.0.6"
nginx_v="1.21.1"
libzip_v="1.7.3"
libiconv_v="1.16"
# db
mysql_v="8.0.27"
mariadb_v="10.6.17"
# database tools
adminer_version="4.8.1"
phpmyadmin_version="5.1.0"
# Application installation directory,Can be changed as needed
soft_dir="/opt"
account_log="/tmp/account-renwole.log"
web_dir="/apps/web/default"
nginx_install_dir="/apps/server/nginx"
php_install_dir="/apps/server/php"
# MySQL install database PATH
mysql_install_dir="/apps/server/mysql"
mysql_data_dir="/apps/server/mysql/data"
# MariaDB install database PATH
mariadb_install_dir="/apps/server/mariadb"
mariadb_data_dir="/apps/server/mariadb/data"
# Zabbix Monitoring System
zabbix_v="6.4.9"
zabbix_dbname="zabbix"
zabbix_dbuser="zabbix"
zabbix_dbpwd="zabbix"
zabbix_install_dir="/apps/server/zabbix"
mirrors_zabbix="https://cdn.zabbix.com"
zabbix_file="/apps/server/zabbix/etc/zabbix_server.conf"
# The analytics platform for all your metrics
grafana_version="10.2.3"
# System config
timezone="Asia/Shanghai"
dbroot_password="I#p1%sX@Renwole"
cpu_thread=`grep "processor" /proc/cpuinfo | sort -u | wc -l`
# Application package download
mirrors_nginx="http://mirrors.sohu.com"
mirrors_php="http://mirrors.sohu.com"
mirrors_libiconv="http://mirrors.ustc.edu.cn"
mirrors_libzip="https://renwole.com"
mirrors_libzip2="https://libzip.org"
mirrors_phpmyadmin="https://renwole.com"
mirrors_mysql="http://mirrors.sohu.com"
mirrors_mariadb="http://mirrors.ustc.edu.cn"
# Text coloring
Redecho() {
printf '\033[31m%s\033[0m\n' "$1"
}
Greenecho() {
printf '\033[32m%s\033[0m\n' "$1"
}
Yellowecho() {
printf '\033[33m%s\033[0m\n' "$1"
}
# Must be root user to execute
if [[ $(whoami) != "root" ]]; then
Redecho "Need root user to deploy"
exit 1
fi
Check_NetWork() {
NetWork_status=`curl -sI https://renwole.com | awk '/HTTP/{print $2}'`
[[ "${NetWork_status}" -ne 200 ]] && Redecho "No Internet!" && exit 1
}
# System initialization
System_Init() {
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
setenforce 0
if ps -A | grep firewalld > /dev/null 2>&1; then
firewall-cmd --permanent --zone=public --add-port={80,443,3306,3000}/tcp
firewall-cmd --reload
fi
echo "fs.file-max=65535" >> /etc/sysctl.conf
}
Download_Package() {
[[ -s "${url_src##*/}" ]] && echo "${url_src##*/} found" || { wget --progress=bar:force --limit-rate=30M -4 --tries=6 -c --no-check-certificate ${url_src}; sleep 1; }
if [[ ! -e "${url_src##*/}" ]]; then
Redecho "Auto download failed! You can manually download ${url_src} into the /opt directory."
kill -9 $$
fi
}
# Install common independent dependencies.
Generic_packages() {
[[ ! -e "/etc/yum.repos.d/epel.repo" ]] && dnf -y install epel-release
dnf makecache
[[ -e "/etc/yum.repos.d/CentOS-PowerTools.repo" ]] && dnf config-manager --set-enabled PowerTools
for packages in wget tar curl gcc gcc-c++ make cmake3 openssl openssl-devel libaio;
do dnf -y install ${packages}; done
ln -sf /usr/bin/cmake3 /usr/bin/cmake > /dev/null 2>&1
dnf install ncurses ncurses-compat-libs -y
}
# Nginx dependent packages
Nginx_with_packages() {
for packages in gd gd-devel pcre pcre-devel pcre2 pcre2-devel automake zlib zlib-devel;
do dnf -y install ${packages}; done
}
# Installation Nginx
Install_Nginx() {
dnf install jemalloc jemalloc-devel -y
groupadd www > /dev/null 2>&1
useradd -s /sbin/nologin -M -g www www > /dev/null 2>&1
[[ ! -e "${web_dir}" ]] && mkdir -p ${web_dir}
[[ ! -e "${nginx_install_dir}" ]] && mkdir -p ${nginx_install_dir}
ulimit -SHn 65535
cd ${soft_dir}
url_src="${mirrors_nginx}/nginx/nginx-${nginx_v}.tar.gz" && Download_Package
tar zxvf nginx-${nginx_v}.tar.gz
cd nginx-${nginx_v}
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
./configure --prefix=${nginx_install_dir} --user=www --group=www --with-http_v2_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-http_slice_module --with-threads --with-file-aio --with-stream --with-stream_ssl_module --with-pcre --with-pcre-jit --with-ld-opt='-ljemalloc'
make -j ${cpu_thread} && make install
# Whether the installation is successful
if [[ -e "${nginx_install_dir}/sbin/nginx" ]]; then
rm -rf ${soft_dir}/nginx-${nginx_v}
rm -rf ${soft_dir}/nginx-${nginx_v}.tar.gz
else
rm -rf ${nginx_install_dir}
rm -rf ${soft_dir}/nginx-${nginx_v}.tar.gz
Redecho "ERROR: Nginx install failed, Please Contact the author!"
exit 1
fi
# Import Nginx configuration file
cat > ${nginx_install_dir}/conf/nginx.conf << EOF
user www www;
worker_processes auto;
error_log ${nginx_install_dir}/logs/error_nginx.log crit;
pid ${nginx_install_dir}/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 1024m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
# Gzip Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_min_length 312;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "MSIE [1-6]\.";
#################### Renwole and default ########################
server {
listen 80 default_server;
server_name _;
# 301 Permanent redirect
# return 301 http://www.renwole.com$request_uri;
access_log ${web_dir}/access_nginx.log combined;
root ${web_dir};
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
# Wordpress Rewrite
# location / { try_files $uri $uri/ /index.php?$args; }
# Wordpress Deny access to PHP files in specific directory
# location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
location ~ [^/]\.php(/|$) {
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
deny all;
}
}
###################### Renwole New vhost #########################
include ${nginx_install_dir}/conf/vhosts/*.conf;
}
EOF
# Import systemctl Nginx startup file
cat > /lib/systemd/system/nginx.service << EOF
[Unit]
Description=nginx - high performance web server
After=network.target
[Service]
Type=forking
PIDFile=${nginx_install_dir}/logs/nginx.pid
ExecStartPost=/bin/sleep 0.1
ExecStartPre=${nginx_install_dir}/sbin/nginx -t -c ${nginx_install_dir}/conf/nginx.conf
ExecStart=${nginx_install_dir}/sbin/nginx -c ${nginx_install_dir}/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
EOF
echo 'PATH=$PATH:'${nginx_install_dir}'/sbin' > /etc/profile.d/nginx-renwole.sh
systemctl enable nginx.service
systemctl restart nginx.service
}
echo "===========================================" >> ${account_log}
echo "Thank you for using Renwole.com script" >> ${account_log}
# MariaDB Binary installation
Install_MariaDB() {
useradd -M -s /sbin/nologin mariadb > /dev/null 2>&1
[[ ! -e "${mariadb_install_dir}" ]] && mkdir -p ${mariadb_install_dir}
cd ${soft_dir}
url_src="${mirrors_mariadb}/mariadb/mariadb-${mariadb_v}/bintar-linux-systemd-x86_64/mariadb-${mariadb_v}-linux-systemd-x86_64.tar.gz" && Download_Package
tar zxf mariadb-${mariadb_v}-linux-systemd-x86_64.tar.gz
\mv mariadb-${mariadb_v}-linux-systemd-x86_64/* ${mariadb_install_dir}
# MariaDB whether the installation is successful
if [[ -d "${mariadb_install_dir}/scripts" ]]; then
rm -rf mariadb-${mariadb_v}-linux-systemd-x86_64
rm -rf ${soft_dir}/mariadb-${mariadb_v}-linux-systemd-x86_64.tar.gz
else
rm -rf ${mariadb_install_dir}
rm -rf ${soft_dir}/mariadb-${mariadb_v}-linux-systemd-x86_64.tar.gz
Redecho "ERROR: MariaDB install failed, Please contact the author!"
exit 1
fi
\cp -f ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld
sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/lib64/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
rm -rf /etc/profile.d/{mysql,mariadb}*.sh
echo 'PATH=$PATH:'${mariadb_install_dir}'/bin' > /etc/profile.d/mariadb-renwole.sh
# Import MariaDB configuration file
cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = ${mariadb_install_dir}
datadir = ${mariadb_data_dir}
pid-file = ${mariadb_data_dir}/mysql.pid
user = mariadb
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7
log_error = ${mariadb_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${mariadb_data_dir}/mysql-slow.log
performance_schema = 0
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 500M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF
# Initialize MariaDB configuration
chown -R mariadb:mariadb ${mariadb_install_dir}
${mariadb_install_dir}/scripts/mysql_install_db --user=mariadb --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
systemctl start mysqld
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'%' identified by \"${dbroot_password}\" with grant option;"
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbroot_password}\" with grant option;"
${mariadb_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "delete from mysql.user where Password='';"
${mariadb_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "delete from mysql.db where User='';"
${mariadb_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "delete from mysql.proxies_priv where Host!='localhost';"
${mariadb_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "drop database test;"
${mariadb_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb}*.conf
echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/mariadb-renwole.conf
ldconfig
echo "===========================================" >> ${account_log}
echo "RootUser: root" >> ${account_log}
echo "RootPasswd: ${dbroot_password}" >> ${account_log}
}
# MySQL Binary installation
Install_MySQL() {
useradd -M -s /sbin/nologin mysql > /dev/null 2>&1
[[ ! -e "${mysql_install_dir}" ]] && mkdir -p ${mysql_install_dir}
cd ${soft_dir}
url_src="${mirrors_mysql}/mysql/MySQL-8.0/mysql-${mysql_v}-linux-glibc2.12-x86_64.tar.xz" && Download_Package
tar xJf mysql-${mysql_v}-linux-glibc2.12-x86_64.tar.xz
\mv mysql-${mysql_v}-linux-glibc2.12-x86_64/* ${mysql_install_dir}
# MySQL whether the installation is successful
if [[ -d "${mysql_install_dir}/support-files" ]]; then
rm -rf mysql-${mysql_v}-linux-glibc2.12-x86_64
rm -rf ${soft_dir}/mysql-${mysql_v}-linux-glibc2.12-x86_64.tar.xz
else
rm -rf ${mysql_install_dir}
rm -rf ${soft_dir}/mysql-${mysql_v}-linux-glibc2.12-x86_64.tar.xz
Redecho "ERROR: MySQL install failed, Please contact the author!"
exit 1
fi
\cp -f ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/lib64/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
rm -rf /etc/profile.d/{mysql,mariadb}*.sh
echo 'PATH=$PATH:'${mysql_install_dir}'/bin' > /etc/profile.d/mysql-renwole.sh
# Import MySQL configuration file
cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysql]
prompt="MySQL [\\d]> "
no-auto-rehash
[mysqld]
port = 3306
socket = /tmp/mysql.sock
default_authentication_plugin = mysql_native_password
basedir = ${mysql_install_dir}
datadir = ${mysql_data_dir}
pid-file = ${mysql_data_dir}/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
collation-server = utf8mb4_0900_ai_ci
skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
binlog_expire_logs_seconds = 604800
log_error = ${mysql_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${mysql_data_dir}/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 500M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF
# Initialize MariaDB configuration
chown -R mysql:mysql ${mysql_install_dir}
${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
systemctl start mysqld
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'%' identified by \"${dbroot_password}\";"
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'%' with grant option;"
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;"
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbroot_password}\";"
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'%' identified by \"${dbroot_password}\";"
${mysql_install_dir}/bin/mysql -uroot -p${dbroot_password} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf
echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/mysql-renwole.conf
ldconfig
echo "===========================================" >> ${account_log}
echo "RootUser: root" >> ${account_log}
echo "RootPasswd: ${dbroot_password}" >> ${account_log}
}
# PHP dependencies
PHP_with_packages() {
for packagesr in boost169-devel bison libargon2 libargon2-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libsodium libsodium-devel libxslt libxslt-devel libcurl libcurl-devel libxml2 libxml2-devel libevent libevent-devel libidn2 libidn2-devel libicu-devel glib2 glib2-devel glibc glibc-devel gmp gmp-devel ncurses ncurses-devel openldap-devel oniguruma-devel freetype freetype-devel mhash readline readline-devel sqlite-devel autoconf libtool*;
do dnf -y install $packagesr; done
}
PHP_with_libiconv() {
if [[ ! -e "/usr/local/libiconv/lib/libiconv.la" ]]; then
cd ${soft_dir}
url_src="${mirrors_libiconv}/gnu/libiconv/libiconv-${libiconv_v}.tar.gz" && Download_Package
tar zxf libiconv-${libiconv_v}.tar.gz
cd libiconv-${libiconv_v}
./configure --prefix=/usr/local/libiconv
make -j ${cpu_thread}
make install
rm -rf ${soft_dir}/libiconv-${libiconv_v}*
fi
}
PHP_with_libzip() {
if [[ ! -e "/usr/lib64/libzip.so" ]]; then
cd ${soft_dir}
url_src="${mirrors_libzip}/sh/src/libzip-${libzip_v}.tar.gz" && Download_Package
tar xzf libzip-${libzip_v}.tar.gz
cd libzip-${libzip_v}
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make -j ${cpu_thread}
make install
rm -rf ${soft_dir}/libzip-${libzip_v}*
fi
}
Check_library() {
ln -sf /usr/lib64/libldap* /usr/lib > /dev/null 2>&1
ln -sf /usr/lib64/liblber* /usr/lib > /dev/null 2>&1
ln -sf /usr/local/libiconv/lib/libiconv.so.2 /usr/lib > /dev/null 2>&1
echo "/usr/lib64" > /etc/ld.so.conf.d/local-renwole.conf
echo "/usr/local/lib" > /etc/ld.so.conf.d/local-renwole.conf
ldconfig > /dev/null 2>&1
}
# installation PHP
Install_PHP() {
cd ${soft_dir}
[[ ! -e "${php_install_dir}" ]] && mkdir -p ${php_install_dir}/etc/php.d
if [[ "${php_option}" -eq 1 ]]; then
url_src="${mirrors_php}/php/php-${php_74_version}.tar.gz" && Download_Package
tar zxf php-${php_74_version}.tar.gz
cd php-${php_74_version}
else
url_src="${mirrors_php}/php/php-${php_80_version}.tar.gz" && Download_Package
tar zxf php-${php_80_version}.tar.gz
cd php-${php_80_version}
fi
./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc --with-config-file-scan-dir=${php_install_dir}/etc/php.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv=/usr/local/libiconv --with-freetype --with-jpeg --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-sockets --with-xmlrpc --with-zip --with-xsl --with-gettext --with-sodium --enable-soap --enable-exif --enable-opcache --disable-fileinfo --disable-debug --with-password-argon2 --enable-ctype --with-ldap --with-gmp
make ZEND_EXTRA_LIBS='-liconv' -j ${cpu_thread}
make install
\cp -f php.ini-production ${php_install_dir}/etc/php.ini
# PHP whether the installation is successful
if [[ -e "${php_install_dir}/bin/phpize" ]]; then
rm -rf ${soft_dir}/php-*
else
rm -rf ${php_install_dir}
Redecho "ERROR: PHP install Failed, Please Contact the author!"
exit 1
fi
sed -i "s@^memory_limit.*@memory_limit = 128M@" ${php_install_dir}/etc/php.ini \
&& sed -i "s@^max_input_time.*@max_input_time = 301@" ${php_install_dir}/etc/php.ini \
&& sed -i 's@^post_max_size.*@post_max_size = 50M@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini \
&& sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini \
&& sed -i 's@^max_execution_time.*@max_execution_time = 300@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 4M@' ${php_install_dir}/etc/php.ini \
&& sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini
echo 'PATH=$PATH:'${php_install_dir}'/bin' > /etc/profile.d/php-renwole.sh
# Import opcache configuration file
cat > ${php_install_dir}/etc/php.d/opcache-renwole.ini << EOF
[opcache]
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=6000
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.consistency_checks=0
EOF
# Import php-fpm configuration file
cat > ${php_install_dir}/etc/php-fpm.conf << EOF
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = warning
emergency_restart_threshold = 30
emergency_restart_interval = 60s
process_control_timeout = 5s
daemonize = yes
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 12
pm.start_servers = 8
pm.min_spare_servers = 6
pm.max_spare_servers = 12
pm.max_requests = 2048
pm.process_idle_timeout = 10s
request_terminate_timeout = 140
request_slowlog_timeout = 0
EOF
# Import systemctl php-fpm startup file
cat > /usr/lib/systemd/system/php-fpm.service << EOF
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=${php_install_dir}/var/run/php-fpm.pid
ExecStart=${php_install_dir}/sbin/php-fpm --nodaemonize --fpm-config ${php_install_dir}/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
EOF
systemctl enable php-fpm.service
systemctl restart php-fpm.service
}
Install_Adminer() {
cd ${soft_dir}
url_src="https://github.com/vrana/adminer/releases/download/v${adminer_version}/adminer-${adminer_version}.php" && Download_Package
\mv adminer-${adminer_version}.php ${web_dir}
echo "===========================================" >> ${account_log}
echo "Adminer: http://IP/adminer-${adminer_version}.php" >> ${account_log}
}
# Install Database management tools
Install_phpMyAdmin() {
cd ${soft_dir}
url_src="${mirrors_phpmyadmin}/sh/src/phpMyAdmin-${phpmyadmin_version}-all-languages.tar.gz" && Download_Package
tar xzf phpMyAdmin-${phpmyadmin_version}-all-languages.tar.gz
\mv phpMyAdmin-${phpmyadmin_version}-all-languages ${web_dir}/phpmyadmin
\cp ${web_dir}/phpmyadmin/{config.sample.inc.php,config.inc.php}
mkdir ${web_dir}/phpmyadmin/{upload,save}
sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${web_dir}/phpmyadmin/config.inc.php
sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${web_dir}/phpmyadmin/config.inc.php
sed -i "s@host'\].*@host'\] = '127.0.0.1';@" ${web_dir}/phpmyadmin/config.inc.php
sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(date|base64|head -c 32)\';@" ${web_dir}/phpmyadmin/config.inc.php
echo "<?phpinfo()?>" > ${web_dir}/php.php
chmod 755 -R ${web_dir}/phpmyadmin
chown www.www -R ${web_dir}
if [[ -e "${web_dir}/phpmyadmin" ]]; then
Greenecho "phpMyAdmin [OK]"
rm -rf ${soft_dir}/phpMyAdmin-${phpmyadmin_version}-all-languages.tar.gz
echo "===========================================" >> ${account_log}
echo "PHPInfo: http://IP/php.php" >> ${account_log}
echo "phpMyAdmin: http://IP/phpmyadmin" >> ${account_log}
else
rm -rf ${soft_dir}/phpMyAdmin-${phpmyadmin_version}-all-languages.tar.gz
Redecho "ERROR: phpMyAdmin Install failed"
fi
}
# Installation Zabbix Monitoring System
Zabbix_with_packages() {
for packages in mysql-devel mysql++-devel openssl11-devel net-snmp-devel OpenIPMI-devel libssh2-devel java-devel pcre pcre-devel pcre2 pcre2-devel libcurl libcurl-devel libxml2 libxml2-devel libevent libevent-devel openldap-devel; do
dnf -y install ${packages}; done
}
Install_Zabbix(){
. /etc/profile
[[ $(id -u zabbix >/dev/null 2>&1) != "0" ]] && groupadd --system zabbix > /dev/null 2>&1 && useradd --system -g zabbix -s /sbin/nologin zabbix
cd ${soft_dir}
url_src="${mirrors_zabbix}/zabbix/sources/stable/6.4/zabbix-${zabbix_v}.tar.gz" && Download_Package
tar zxf zabbix-${zabbix_v}.tar.gz
cd zabbix-${zabbix_v}
if [[ "${Zabbix_option}" -eq 1 ]]; then
export CFLAGS="-std=gnu99"
./configure --prefix=${zabbix_install_dir} --sysconfdir=${zabbix_install_dir}/etc --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-proxy --enable-ipv6 --enable-java --with-ssh2 --with-iconv --with-openipmi --with-ldap
make install
# Whether the installation is successful
if [[ ! -e ${zabbix_install_dir}/sbin/zabbix_server ]]; then
rm -rf ${zabbix_install_dir}
Redecho "Zabbix install Failed, Please Contact the author"
exit 1
fi
# Configure zabbix_server.conf file
sed -i "/^DBName=/c DBName=${zabbix_dbname}" ${zabbix_file} \
&& sed -i "/^DBUser=/c DBName=${zabbix_dbuser}" ${zabbix_file} \
&& sed -i "/^# DBPassword=/c DBPassword=${zabbix_dbpwd}" ${zabbix_file} \
&& sed -i '/^# DBSocket=/c DBSocket=/tmp/mysql.sock' ${zabbix_file} \
&& sed -i '/^# LogFileSize=/c LogFileSize=4' ${zabbix_file} \
&& sed -i '/^# StartPingers=/c StartPingers=4' ${zabbix_file} \
&& sed -i '/^# StartDiscoverers=/c StartDiscoverers=8' ${zabbix_file} \
&& sed -i '/^# CacheSize=/c CacheSize=128M' ${zabbix_file} \
&& sed -i '/^# CacheUpdateFrequency=/c CacheUpdateFrequency=120' ${zabbix_file} \
&& sed -i '/^# HistoryCacheSize=/c HistoryCacheSize=256M' ${zabbix_file} \
&& sed -i '/^# HistoryIndexCacheSize=/c HistoryIndexCacheSize=64M' ${zabbix_file} \
&& sed -i '/^# TrendCacheSize=/c TrendCacheSize=64M' ${zabbix_file} \
&& sed -i '/^# ValueCacheSize=/c ValueCacheSize=128M' ${zabbix_file} \
&& sed -i "/^LogFile=/c LogFile=${zabbix_install_dir}/logs/zabbix_server.log" ${zabbix_file} \
&& sed -i "/^# PidFile=/c PidFile=${zabbix_install_dir}/logs/zabbix_server.pid" ${zabbix_file}
# Set Zabbix variable
echo 'PATH=$PATH:'${zabbix_install_dir}'/sbin' > /etc/profile.d/zabbix-renwole.sh
echo "/usr/lib64/mysql" > /etc/ld.so.conf.d/zabbix-renwole.conf
ldconfig > /dev/null 2>&1
# Configure zabbix management panel
[[ -e "/apps/web/default" ]] && /bin/cp -rf ui ${web_dir}
[[ ! -e "${zabbix_install_dir}/logs" ]] && mkdir -p ${zabbix_install_dir}/logs
chown -R www.www ${web_dir}
chown -R zabbix.zabbix ${zabbix_install_dir}
# Create zabbix database information
Yellowecho "Import Zabbix DataBase..."
if command -v mysql > /dev/null 2>&1; then
# New zabbix database
mysql -uroot -p${dbroot_password} -e "create database ${zabbix_dbname} character set utf8 collate utf8_bin;" 1>/dev/null
mysql -uroot -p${dbroot_password} -e "create user '${zabbix_dbuser}'@'%' identified by '${zabbix_dbpwd}';" 1>/dev/null
mysql -uroot -p${dbroot_password} -e "create user '${zabbix_dbuser}'@'localhost' identified by '${zabbix_dbpwd}';" 1>/dev/null
mysql -uroot -p${dbroot_password} -e "grant all privileges on ${zabbix_dbname}.* to '${zabbix_dbuser}'@'%' with grant option;" 1>/dev/null
mysql -uroot -p${dbroot_password} -e "grant all privileges on ${zabbix_dbname}.* to '${zabbix_dbuser}'@'localhost' with grant option;" 1>/dev/null
# Import zabbix database
mysql -uroot -p${dbroot_password} ${zabbix_dbname} < database/mysql/schema.sql
mysql -uroot -p${dbroot_password} ${zabbix_dbname} < database/mysql/images.sql
mysql -uroot -p${dbroot_password} ${zabbix_dbname} < database/mysql/data.sql
Greenecho "Import Zabbix DataBase Successfully"
else
Redecho "Create Zabbix database Failed, Please create a database and import Zabbix data table files in order: database/mysql/schema.sql/images.sql/data.sql!"
fi
# Create Zabbix server startup file
cat > /usr/lib/systemd/system/zabbix.service << EOF
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Type=forking
Restart=always
RestartSec=60
TimeoutSec=0
Environment="CONFFILE=${zabbix_file}"
EnvironmentFile=-${zabbix_install_dir}/etc/zabbix_server.conf.d
PIDFile=${zabbix_install_dir}/logs/zabbix_server.pid
KillMode=control-group
ExecStart=${zabbix_install_dir}/sbin/zabbix_server -c \$CONFFILE
ExecStop=/bin/kill -SIGTERM \$MAINPID
[Install]
WantedBy=multi-user.target
EOF
systemctl enable zabbix.service
systemctl restart zabbix.service
echo "===========================================" >> ${account_log}
echo "Zabbix DBName: ${zabbix_dbname}" >> ${account_log}
echo "Zabbix DBUser: ${zabbix_dbuser}" >> ${account_log}
echo "Zabbix DBPasswd: ${zabbix_dbpwd}" >> ${account_log}
echo "===========================================" >> ${account_log}
echo "Zabbix UIWeb: http://IP/ui" >> ${account_log}
echo "Zabbix User/Passwd: Admin/zabbix" >> ${account_log}
else
./configure --prefix=${zabbix_install_dir} --sysconfdir=${zabbix_install_dir}/etc --enable-agent
make install
sed -i "s#Server=.*#Server=0.0.0.0#" ${zabbix_install_dir}/etc/zabbix_agentd.conf \
&& sed -i "s#ServerActive=.*#ServerActive=0.0.0.0#" ${zabbix_install_dir}/etc/zabbix_agentd.conf \
&& sed -i "/^LogFile=/c LogFile=${zabbix_install_dir}/logs/zabbix_agentd.log" ${zabbix_install_dir}/etc/zabbix_agentd.conf \
&& sed -i "/^# PidFile=/c PidFile=${zabbix_install_dir}/logs/zabbix_agentd.pid" ${zabbix_install_dir}/etc/zabbix_agentd.conf
[[ ! -e "${zabbix_install_dir}/logs" ]] && mkdir -p ${zabbix_install_dir}/logs
chown -R zabbix.zabbix ${zabbix_install_dir}
# Create Zabbix Agent startup file
cat > /usr/lib/systemd/system/zabbix-agent.service << EOF
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Type=forking
Restart=always
RestartSec=60
TimeoutSec=0
Environment="CONFFILE=${zabbix_install_dir}/etc/zabbix_agentd.conf"
EnvironmentFile=-${zabbix_install_dir}/etc/zabbix_agent.conf.d
PIDFile=${zabbix_install_dir}/logs/zabbix_agentd.pid
KillMode=control-group
ExecStart=${zabbix_install_dir}/sbin/zabbix_agentd -c \$CONFFILE
ExecStop=/bin/kill -SIGTERM \$MAINPID
[Install]
WantedBy=multi-user.target
EOF
systemctl enable zabbix-agent.service
systemctl restart zabbix-agent.service
fi
}
# Grafana system
Install_Grafana() {
cd ${soft_dir}
url_src="https://repo.huaweicloud.com/grafana/${grafana_version}/grafana-enterprise-${grafana_version}-1.x86_64.rpm" && Download_Package
sudo dnf -y install grafana-enterprise-${grafana_version}-1.x86_64.rpm
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
echo "===========================================" >> ${account_log}
echo "Grafana WebUI: http://IP:3000" >> ${account_log}
echo "Grafana User/Passwd: admin/admin" >> ${account_log}
}
Check_Service() {
# Check Nginx
if [[ -e "${nginx_install_dir}/sbin/nginx" ]]; then
if ps -A | grep nginx > /dev/null 2>&1; then
Greenecho "Nginx Start [OK]"
else
Redecho "ERROR: Nginx Start Failure"
fi
else
Yellowecho "Nginx is not installed"
fi
# Check MariaDB
if [[ -d "${mariadb_install_dir}/scripts" ]]; then
if ps -A | grep mysqld > /dev/null 2>&1; then
Greenecho "MariaDB Start [OK]"
else
Redecho "ERROR: MariaDB Start Failure"
fi
else
Yellowecho "MariaDB is not installed"
fi
# Chack MySQL
if [[ -d "${mysql_install_dir}/support-files" ]]; then
if ps -A | grep mysqld > /dev/null 2>&1; then
Greenecho "MySQL Start [OK]"
else
Redecho "ERROR: MySQL Start Failure"
fi
else
Yellowecho "MySQL is not installed"
fi
# Chack PHP
if [[ -e "${php_install_dir}/bin/phpize" ]]; then
if ps -A | grep php-fpm > /dev/null 2>&1; then
Greenecho "PHP Start [OK]"
else
Redecho "ERROR: PHP Start Failure"
fi
else
Yellowecho "PHP is not installed"
fi
# Chack Zabbix Server
if [[ -e "${zabbix_install_dir}/sbin/zabbix_server" ]]; then
if ps -A | grep zabbix > /dev/null 2>&1; then
Greenecho "Zabbix Server Start [OK]"
else
Redecho "Zabbix Server Start Failure"
fi
else
Yellowecho "Zabbix Server is not installed"
fi
# Chack Zabbix Agent
if [[ -e "${zabbix_install_dir}/sbin/zabbix_agentd" ]]; then
if ps -A | grep zabbix_agentd > /dev/null 2>&1; then
Greenecho "Zabbix Agent Start [OK]"
else
Redecho "Zabbix Agent Start Failure"
fi
else
Yellowecho "Zabbix Agent is not installed"
fi
# Chack Grafana
if [[ -e "/lib/systemd/system/grafana-server.service" ]]; then
if ps -A | grep grafana > /dev/null 2>&1; then
Greenecho "Grafana Start [OK]"
else
Redecho "Grafana Start Failure"
fi
else
Yellowecho "Grafana is not installed"
fi
/bin/cat ${account_log}
}
# Select Web Server
while :; do
read -e -p "Whether to install Web service? [y/n]:" web_yn
if [[ ! "${web_yn}" =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${web_yn}" == "y" ]]; then
break
else
break
fi
fi
done
# Select DataBase
while :; do
read -e -p "Whether to install the database? [y/n]: " db_yn
if [[ ! "${db_yn}" =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${db_yn}" == "y" ]]; then
while :; do
Yellowecho "Please select a database version:"
echo -e "1. install MySQL ${mysql_v}"
echo -e "2. install MariaDB ${mariadb_v}"
read -e -p "Please enter the number (Default 1 Enter) :" db_option
db_option=${db_option:-1}
if [[ ! ${db_option} =~ ^[1-2]$ ]]; then
Redecho "ERROR: Please enter 1 or 2"
else
break
fi
done
fi
break
fi
done
# Select PHP
while :; do
read -e -p "Whether to install PHP? [y/n]: " php_yn
if [[ ! ${php_yn} =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${php_yn}" == "y" ]]; then
while :; do
Yellowecho "Please select a php version:"
echo -e "1. install php ${php_74_version}"
echo -e "2. install php ${php_80_version}"
read -e -p "Please enter the number (Default 1 Enter) :" php_option
php_option=${php_option:-1}
if [[ ! ${php_option} =~ ^[1-2]$ ]]; then
Redecho "ERROR: Please enter 1 or 2"
else
break
fi
done
fi
break
fi
done
# Select Database management tools
while :; do
read -e -p "Whether to install Database Management Tools? [y/n]: " DMT_yn
if [[ ! ${DMT_yn} =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${DMT_yn}" == "y" ]]; then
while :; do
Yellowecho "Please select Database Management Tools:"
echo -e "1. install Adminer ${adminer_version}"
echo -e "2. install phpMyadmin ${phpmyadmin_version}"
read -e -p "Please enter the number (Default 1 Enter) :" DMT_option
DMT_option=${DMT_option:-1}
if [[ ! ${DMT_option} =~ ^[1-2]$ ]]; then
Redecho "ERROR: Please enter 1 or 2"
else
break
fi
done
fi
break
fi
done
# Select Zabbix
while :; do
read -e -p "Whether to install Zabbix Monitoring System? [y/n]: " zabbix_yn
if [[ ! ${zabbix_yn} =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${zabbix_yn}" == "y" ]]; then
while :; do
Yellowecho "Please select Zabbix:"
echo -e "1. install Zabbix Server ${zabbix_v}"
echo -e "2. install Zabbix Agent ${zabbix_v}"
read -e -p "Please enter the number (Default 1 Enter) :" Zabbix_option
Zabbix_option=${Zabbix_option:-1}
if [[ ! ${Zabbix_option} =~ ^[1-2]$ ]]; then
Redecho "ERROR: Please enter 1 or 2"
else
break
fi
done
fi
break
fi
done
# Select Grafana
while :; do
read -e -p "Whether to install Grafana? [y/n]: " grafana_yn
if [[ ! ${grafana_yn} =~ ^[y,n]$ ]]; then
Redecho "ERROR: Please enter y or n"
else
if [[ "${grafana_yn}" == "y" ]]; then
break
else
break
fi
fi
done
# Check system version
linux_release=`cat /etc/*-release | grep -oE "[0-9.]+" | head -n2 |tail -n1`
if [[ "${linux_release}" -lt 7 ]]; then
Redecho "Must be Centos7.x or Centos8.x system to install"
exit 1
else
command -v dnf > /dev/null 2>&1 || { [[ -e "/etc/redhat-release" ]] && yum upgrade python* -y && yum -y install dnf; }
Check_NetWork 2>&1 | tee -a /tmp/install.log
System_Init 2>&1 | tee -a /tmp/install.log
Generic_packages 2>&1 | tee -a /tmp/install.log
fi
# Install Web server with conditions
case "${web_yn}" in
y)
Nginx_with_packages 2>&1 | tee -a /tmp/install.log
Install_Nginx 2>&1 | tee -a /tmp/install.log
;;
esac
# Install Database with conditions
case "${db_option}" in
1)
Install_MySQL 2>&1 | tee -a /tmp/install.log
;;
2)
Install_MariaDB 2>&1 | tee -a /tmp/install.log
;;
esac
# Install PHP with conditions
case "${php_yn}" in
y)
PHP_with_packages 2>&1 | tee -a /tmp/install.log
PHP_with_packages 2>&1 | tee -a /tmp/install.log
PHP_with_libiconv 2>&1 | tee -a /tmp/install.log
PHP_with_libzip 2>&1 | tee -a /tmp/install.log
Check_library 2>&1 | tee -a /tmp/install.log
Install_PHP 2>&1 | tee -a /tmp/install.log
;;
esac
# Install phpMyAdmin or Adminer
case "${DMT_option}" in
1)
Install_Adminer 2>&1 | tee -a /tmp/install.log
;;
2)
Install_phpMyAdmin 2>&1 | tee -a /tmp/install.log
;;
esac
# Install Zabbix with conditions
case "${zabbix_yn}" in
y)
Zabbix_with_packages 2>&1 | tee -a /tmp/install.log
Install_Zabbix 2>&1 | tee -a /tmp/install.log
;;
esac
# Install Zabbix with conditions
case "${grafana_yn}" in
y)
Install_Grafana 2>&1 | tee -a /tmp/install.log
;;
esac
Check_Service 2>&1 | tee -a /tmp/install.log
三、安装方法
#######################################################
# Zabbix Install Tool for CentOS/RedHat 7+ #
# For more please visit https://renwole.com #
#######################################################
【输入'y' 安装 Nginx web服务,也可根据需要选择是否安装】:
Whether to install Web service? [y/n]:y
【支持MySQL/MariaDB,默认安装MySQL8,可根据需要选择1 2,如已装,可选'n'跳过】:
Whether to install the database? [y/n]: y
Please select a database version:
1. install MySQL 8.0.22
2. install MariaDB 10.5.8
Please enter the number (Default 1 Enter) :2(这里必须选2)
【支持PHP7/8两种版本,默认安装PHP7,均为最新版本,可选1,2根据需要选择】:
Whether to install PHP? [y/n]: y
Please select a php version:
1. install php 7.4.15
2. install php 8.0.2
Please enter the number (Default 1 Enter) :1
【支持Adminer/phpMyadmin两种数据库管理工具,也可不装】:
Whether to install Database Management Tools? [y/n]: n(没啥人要懒得更新,必须选n)
Please select Database Management Tools:
1. install Adminer 4.8.0
2. install phpMyadmin 5.0.4
Please enter the number (Default 1 Enter) :2
【支持Zabbix Server/Agent选择安装,除上述,也可独立安装,例如:Agent,可选1,2】:
Whether to install Zabbix Monitoring System? [y/n]: y
Please select Zabbix:
1. install Zabbix Server服务端
2. install Zabbix Agent客户端
Please enter the number (Default 1 Enter) :1
【是否安装Grafana,可配合Zabbix Server根据需要使用,也可不装】:
Whether to install Grafana? [y/n]: y
Zabbix安装后的相关信息:
centos系统的账号密码为 root 2wsx#EDC(虚拟机镜像系统密码)
Zabbix UI入口:http://IP/ui
Zabbix管理平台账号密码:Admin/zabbix
Zabbix数据库/账号/密码:zabbix/zabbix/zabbix
四、配置客户端
Linux端安装agent 并配置服务器地址
清华大学开源软件镜像站 | Tsinghua Open Source Mirror
windows 端安装 windows agent 客户端 并配置服务器地址
windows端在zabbix官网下载