架構組合:nginx1.9.10+php7.0.32+mysql5.7.22+zabbix4.0.1 nginx1.9.10 先裝依賴 openssl-1.1.0f pcre-8.40 zlib-1.2.11 nginx-1.9.10 編譯 安裝 php7.0.32 php使用yum方式安裝 更新y ...
架構組合:nginx1.9.10+php7.0.32+mysql5.7.22+zabbix4.0.1
nginx1.9.10
先裝依賴
tar zxvf openssl-1.1.0f.tar.gz cd openssl-1.1.0f ./config --prefix=/usr/local/lib/openssl-1.1.0f make && make install
tar zxvf pcre-8.40.tar.gz cd pcre-8.40 ./configure --prefix=/usr/local/lib/pcre-8.40 make && make install
tar zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure --prefix=/usr/local/lib/zlib-1.2.11 make && make install
nginx-1.9.10
tar -zxvf nginx-1.9.10.tar.gz cd nginx-1.9.10
編譯
./configure --prefix=/usr/local/nginx-1.9.10/ --with-pcre=/usr/local/lib/pcre-8.40/ --with-openssl=/usr/local/lib/openssl-1.1.0f/ --with-zlib=/usr/local/lib/zlib-1.2.11/
安裝
make && make install
php7.0.32
php使用yum方式安裝
更新yum源
CentOS/RHEL 7:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm url:https://centos.pkgs.org/7/webtatic-x86_64/webtatic-release-7-3.noarch.rpm.html
yum
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel php70w-xml -y
驗證
php -v
查看所有已安裝的模塊
php -m
配置文件詳解
測試
mkdir -p /usr/local/zabbix-4.0.1/php vim index.php
index.php
<?php phpinfo(); ?>
nginx+php配置
cd /usr/local/nginx-1.9.10/conf vim zabbix.conf
zabbix.conf
server{ listen 9088; server_name localhost; access_log logs/zabbix.log; error_log logs/error.log; location / { proxy_http_version 1.1; root /usr/local/zabbix-4.0.1/php; index index.html index.htm index.php; } location ~* \.php$ { root /usr/local/zabbix-4.0.1/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/zabbix-4.0.1/php$fastcgi_script_name; include fastcgi_params; } }
在nginx.conf htpp選項中加入zabbix.conf
include zabbix.conf;
瀏覽器訪問:ip+9088
mysql5.7.22
解壓
tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
新建data,logs目錄用來存放數據和日誌
cd /opt/mysql mkdir data logs
my.cnf
[mysqld] federated datadir=/opt/mysql/data socket=/tmp/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd skip-grant-tables server-id=148 log-bin=mysql-bin lower_case_table_names=1 sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' [mysqld_safe] log-error=/opt/mysql/logs/error.log pid-file=/opt/mysql/mysql.pid # # include all files from the config directory # !includedir /etc/my.cnf.d
初始化
/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data --initialize
啟動命令
/opt/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
登陸後重新設置root密碼
修改授權遠程zabbix密碼 ALTER USER 'zabbix'@'%' IDENTIFIED BY 'zabbix'; 創建zabbix遠程%用戶 CREATE USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'zabbix'; 授權 GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%'; 刷新 flush PRIVILEGES;
zabbix4.0.1
https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz
依賴
yum install libevent libevent-devel libaio gcc libxml* unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre* -y
ld.so.conf
vim /etc/ld.so.conf include ld.so.conf.d/*.conf /opt/mysql/lib
編譯
./configure --prefix=/usr/local/zabbix-4.0.1/ --enable-server --enable-agent --with-mysql=/opt/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l
目錄展示
[root@localhost etc]# cd /usr/local/zabbix-4.0.1/ [root@localhost zabbix-4.0.1]# cd sbin/ [root@localhost sbin]# ls zabbix_agentd zabbix_server [root@localhost sbin]# cd ../etc/ [root@localhost etc]# ls zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d [root@localhost etc]#
php站點轉移
cd /usr/local/zabbix/zabbix-4.0.1/frontends cp -r php /usr/local/zabbix-4.0.1
重啟nginx!
瀏覽器訪問:ip+9088
前面還有配置圖, 我當時沒有截圖,頁面配置好進入登錄界面,預設賬號密碼是admin/zabbix
下麵就是配置添加主機分配監控之類的事了。
自家腳本一鍵操作
客戶端啟動
zagentstartall.sh
#/bin/bash /usr/local/nginx-1.9.10/sbin/nginx /usr/local/php/bin/php-fpm /opt/mysql/start.sh /usr/local/zabbix-4.0.1/sbin/zabbix_agentd
伺服器啟動
zserverstartall.sh
#/bin/bash sudo -u chenglee /usr/local/nginx-1.9.10/sbin/nginx /usr/local/php/bin/php-fpm /opt/mysql/start.sh /usr/local/zabbix-4.0.1/sbin/zabbix_serverl
效果
查看狀態
status.sh
#/bin/bash echo "***************************************" echo "nginx status ..." ps aux | grep nginx echo "php status ..." ps aux | grep php echo "mysql status ..." ps aux | grep mysql echo "zabbix status ..." ps aux | grep zabbix echo "***************************************"l
效果
一鍵kill
stopall.sh
#/bin/bash chengkill nginx chengkill php chengkill mysql chengkill zabbix
效果
chengkill
#!/bin/sh #pid kill thread for chenglee #if fileformat=dos, update fileformat=unix #code:set fileformat=unix #check:set ff ? if [ $# -lt 1 ] then echo "not procedure_name" exit 1 fi PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{ print $2}'` for i in $PROCESS do echo "Kill the $1 process [ $i ]" kill -9 $i done
把chengkill扔進/usr/bin