1. 程式人生 > >開源監控解決方案:ZABBIX部署實錄

開源監控解決方案:ZABBIX部署實錄

lamp zabbix

安裝 Apache HTTP Server

[root@king01 ~]# groupadd apache
[root@king01 ~]# useradd apache -g apache -s /bin/nologin


[root@king01 ~]# tar zxvf apr-1.6.3.tar.gz 
[root@king01 ~]# cd apr-1.6.3
[root@king01 apr-1.6.3]# ./configure --prefix=/usr/local/apr
[root@king01 apr-1.6.3]# make
[root@king01 apr-1.6.3]# make install


[root@king01 ~]# tar zxvf apr-util-1.6.1.tar.gz
[root@king01 apr-util-1.6.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
[root@king01 apr-util-1.6.1]# make
[root@king01 apr-util-1.6.1]# make install


[root@king01 ~]# tar zxvf pcre-8.41.tar.gz
[root@king01 ~]# cd pcre-8.41
[root@king01 pcre-8.41]# ./configure 
[root@king01 pcre-8.41]# make
[root@king01 pcre-8.41]# make install


[root@king01 ~]# tar zxvf httpd-2.4.29.tar.gz
[root@king01 ~]# cd httpd-2.4.29
[root@king01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-ssl --enable-so --enable-cgi --enable-rewrite --with-pcre --with-zlib --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=worker --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config
[root@king01 httpd-2.4.29]# make
[root@king01 httpd-2.4.29]# make install


[root@king01 ~]# vi /etc/httpd/httpd.conf
PidFile  "/var/run/httpd.pid"
ServerName 192.168.1.201:80
User apache
Group apache


[root@king01 ~]# vi /etc/init.d/httpd
#!/bin/bash
 #
 # httpd        Startup script for the Apache HTTP Server
 #
 # chkconfig: - 85 15
 # description: Apache is a World Wide Web server.  It is used to serve  #        HTML files and CGI.
 # processname: httpd
 # config: /etc/httpd/conf/httpd.conf
 # config: /etc/sysconfig/httpd
 # pidfile: /var/run/httpd.pid
# Source function library.
 . /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
         . /etc/sysconfig/httpd
 fi
# Start httpd in the C locale by default.
 HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
 # mod_ssl needs a pass-phrase from the user.
 INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
 # with the thread-based "worker" MPM; BE WARNED that some modules may not
 # work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
 apachectl=/usr/local/apache/bin/apachectl
 httpd=${HTTPD-/usr/local/apache/bin/httpd}
 prog=httpd
 pidfile=${PIDFILE-/var/run/httpd.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/httpd}
 RETVAL=0
start() {
         echo -n $"Starting $prog: "
         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && touch ${lockfile}
         return $RETVAL
 }
stop() {
   echo -n $"Stopping $prog: "
   killproc -p ${pidfile} -d 10 $httpd
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
 }
 reload() {
     echo -n $"Reloading $prog: "
     if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
         RETVAL=$?
         echo $"not reloading due to configuration syntax error"
         failure $"not reloading $httpd due to configuration syntax error"
     else
         killproc -p ${pidfile} $httpd -HUP
         RETVAL=$?
     fi
     echo
 }
# See how we were called.
 case "$1" in
   start)
   start
   ;;
   stop)
   stop
   ;;
   status)
         status -p ${pidfile} $httpd
   RETVAL=$?
   ;;
   restart)
   stop
   start
   ;;
   condrestart)
   if [ -f ${pidfile} ] ; then
     stop
     start
   fi
   ;;
   reload)
         reload
   ;;
   graceful|help|configtest|fullstatus)
   $apachectl $@
   RETVAL=$?
   ;;
   *)
   echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
   exit 1
 esac
exit $RETVAL


[root@king01 ~]# chmod a+x /etc/init.d/httpd
[root@king01 ~]# chkconfig --add httpd
[root@king01 ~]# service httpd start
Starting httpd:                                            [  OK  ]
[root@king01 ~]# service httpd status
httpd (pid  2724) is running...
[root@king01 ~]# netstat -tunlp | grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      2724/httpd


安裝MySQL Server(略)


安裝PHP

[root@zabbix ~]# yum install -y gcc libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel libxml2-devel libcurl-devel

[root@zabbix ~]# tar zxvf php-5.5.30.tar.gz
[root@zabbix ~]# cd php-5.5.30
[root@zabbix php-5.5.30]# ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gettext --with-gd --with-curl --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-bcmath --enable-mbstring --enable-ctype --enable-xml --enable-sockets --enable-shared --disable-ipv6

[root@zabbix php-5.5.30]# make && make install
[root@zabbix php-5.5.30]# cp php.ini-production /etc/php.ini
[root@zabbix php-5.5.30]#  vi /etc/php.ini 
date.timezone = Asia/Shanghai
max_execution_time = 300  
max_input_time = 300
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = off





開源監控解決方案:ZABBIX部署實錄