系统
Centos 6.5
安装包
mysql-5.6.29.tar.gz
nginx-1.10.2.tar.gz
php-5.6.20.tar.gz
zabbix-3.4.1.tar.gz
Nginx安装
依赖安装
$ yum -y install pcre-devel openssl openssl-devel zlib-devel gcc*
新建用户
$ groupadd nginx && useradd -g nginx -s /sbin/nologin nginx
$ tar xf nginx-1.10.2.tar.gz $ cd nginx-1.10.2 $ ./configure --prefix=/soft/nginx --with-http_dav_module \ --with-http_stub_status_module --with-http_addition_module \ --with-http_sub_module --with-http_flv_module --with-http_mp4_module \ --with-pcre --user=nginx --group=nginx $ make && make install $ cd /soft/nginx/conf/
过滤配置文件
$ grep -Ev "#|^$" nginx.conf.default > nginx.conf
$ vim nginx.conf user nginx; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /soft/nginx/html; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.(php|php6)?$ { root /soft/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /soft/nginx/html$fastcgi_script_name; include fastcgi_params; } } }
测试配置文件,返回OK!
$ /soft/nginx/sbin/nginx -t nginx: the configuration file /soft/nginx/conf/nginx.conf syntax is ok nginx: configuration file /soft/nginx/conf/nginx.conf test is successful
MySQL安装
$ yum -y install tree nmap lrzsz dos2unix cmake bison ncurses ncurses-devel $ groupadd mysql && useradd -g mysql -s /sbin/nologin mysql $ cd /soft/mysql-5.6.29 $ cmake -DCMAKE_INSTALL_PREFIX=/soft/mysql \ -DMYSQL_DATADIR=/soft/mysql/data1 \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci $ make && make install $ cp /soft/mysql-5.6.29/support-files/mysql.server /etc/init.d/mysqld $ chmod +x /etc/init.d/mysqld
初始化数据库
$ /soft/mysql/scripts/mysql_install_db --baseir=/soft/mysql --datadir=/soft/mysql/data1 --user=mysql
MySQL配置文件
$ vim /etc/my.cnf [client] socket = /tmp/mysql.sock [mysqld] datadir = /soft/mysql/data1 socket = /tmp/mysql.sock user = mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links = 0 [mysqld_safe] log-error = /var/log/mysqld.log pid-file = /var/run/mysqld/mysqld.pid
修改密码,启动服务
$ mysqladmin -u root password 'testmysql' $ service msyqld start
PHP安装
依赖包安装;
$ yum -y install libxslt libxslt-devel bison bison-devel libmcrypt-devel mcrypt \ mhash-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel \ sqlite-devel jemalloc jemalloc-devel $ groupadd www-data && useradd -g www-data -s /sbin/nologin www-data
如果出现libiconv和libmcrypt安装不上。可用编译安装;
libiconv安装;
$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz $ tar xf libiconv-1.14.tar.gz $ cd libiconv-1.14 $ ./configure $ make && make install
libmcrypt安装;
$ wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz $ tar xf libmcrypt-2.5.7.tar.gz $ cd libmcrypt-2.5.7 $ ./configure $ make && make install
编译安装PHP
$ cd /soft/php-5.6.20 $ ./configure --prefix=/soft/php --with-iconv-dir=/usr --with-freetype-dir \ --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-gettext \ --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem \ --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm \ --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \ --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap \ --enable-short-tags --enable-static --with-xsl --with-fpm-user=www-data \ --with-fpm-group=www-data --enable-ftp --enable-opcache --with-mysql=mysqlnd \ --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd $ make && make install $ cp php.ini-development /soft/php/lib/php.ini $ cd /soft/php/etc $ cp php-fpm.conf.default php-fpm.conf
编译PHP可能会遇到的问题:
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor': /home/king/php-5.6.20/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open' collect2: ld returned 1 exit status make: *** [sapi/cli/php] Error 1
make的时候出现如上错误可修改Makefile文件:
$ vim ./Makefile
EXTRA_LIBS = -lcrypt -lexslt -lcrypt -lrt -lmcrypt -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -lcurl -lxml2 -lz -lm -lssl -lcrypto -lfreetype -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 - lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxslt -lxml2 -lz -lm -lssl -lcrypto -lcrypt -liconv 在EXTRA_LIBS字段最末尾加上-liconv,重新make即可
配置文件主要修改如下:
$ vim /soft/php/lib/php.ini max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 30M date.timezone = Asia/Shanghai always_populate_raw_post_data = -1
启动PHP:
$ /soft/php/sbin/php-fpm
Zabbix安装
编译参数加了JAVA的话,需要安装JDK,不然会报错;
$ tar xf jdk-8u91-linux-x64.tar.gz $ mv jdk1.8.0_91 /soft/jdk1.8
写入环境变量;
$ vim /etc/profile export JAVA_HOME=/soft/jdk1.8 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
立即生效;
$ source /etc/profile
安装依赖;
$ yum install net-snmp-devel libevent-devel -y $ cd /soft/zabbix-3.4.1 $ groupadd zabbix && useradd -g zabbix -s /sbin/nologin zabbix $ ./configure --prefix=/soft/zabbix \ --enable-server --enable-agent --with-mysql \ --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 \ --enable-java $ make && make install
复制启动脚本,注意修改调用路径:BASEDIR=指定安装的目录
$ cp misc/init.d/fedora/core/* /etc/rc.d/init.d/ $ cp -R frontends/php/* /soft/nginx/html/zabbix
$ vim /soft/zabbix/etc/zabbix_server . /etc/init.d/functions BASEDIR=/soft/zabbix BINARY_NAME=zabbix_server FULLPATH=$BASEDIR/sbin/$BINARY_NAME PIDFILE=/tmp/$BINARY_NAME.pid ERROR=0 STOPPING=0 if [ -f $PIDFILE ] && [ -s $PIDFILE ] then PID=`cat $PIDFILE` if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null && [ $BINARY_NAME == `ps -e | grep $PID | awk '{print $4}'` ] then STATUS="$BINARY_NAME (pid `pidof $APP`) running.." RUNNING=1 else rm -f $PIDFILE STATUS="$BINARY_NAME (pid file existed ($PID) and now removed) not running.." RUNNING=0 fi else if [ `ps -e | grep $BINARY_NAME | head -1 | awk '{ print $1 }'` ] then STATUS="$BINARY_NAME (pid `pidof $APP`, but no pid file) running.." else STATUS="$BINARY_NAME (no pid file) not running" fi RUNNING=0 fi start() { if [ $RUNNING -eq 1 ] then echo "$0 $ARG: $BINARY_NAME (pid $PID) already running" else action $"Starting $BINARY_NAME: " $FULLPATH touch /var/lock/subsys/$BINARY_NAME fi } stop() { echo -n $"Shutting down $BINARY_NAME: " killproc $BINARY_NAME RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BINARY_NAME RUNNING=0 } case "$1" in start) start ;; stop) stop ;; status) status $BINARY_NAME ;; restart) stop sleep 10 start ;; help|*) echo $"Usage: $0 {start|stop|status|restart|help}" cat <<EOF start - start $BINARY_NAME stop - stop $BINARY_NAME status - show current status of $BINARY_NAME restart - restart $BINARY_NAME if running by sending a SIGHUP or start if not running help - this screen EOF exit 1 ;; esac exit 0
创建库 用户和权限
mysql> create database zabbix character set utf8; mysql> create user 'zabbix_rw'@'%' identified by 'zabbix'; mysql> grant all on zabbix.* to zabbix_rw@'%' identified by 'zabbix'; mysql> flush privileges; mysql> quit;
导入数据
$ cd database/mysql/ $ mysql -uzabbix -pzabbix zabbix < schema.sql $ mysql -uzabbix -pzabbix zabbix < p_w_picpaths.sql $ mysql -uzabbix -pzabbix zabbix < data.sql
服务端
$ vim /soft/zabbix/etc/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/tmp/mysql.sock DBPort=3306 PidFile=/soft/zabbix/pid/zabbix_server.pid JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5 CacheSize=1024M Timeout=30 AlertScriptsPath=/soft/zabbix/share/zabbix/alertscripts #FpingLocation=/soft/fping/sbin/fping LogSlowQueries=3000
客户端
$ vim /soft/zabbix/etc/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log EnableRemoteCommands=1 Server=192.168.10.128 ServerActive=192.168.10.128 Hostname=zk-192.168.10.128 HostMetadataItem=system.uname Include=/soft/zabbix/etc/zabbix_agentd.conf.d/*.conf
启动
$ service zabbix_server start #服务端 $ service zabbix_agentd start #客户端
WEB认证文件
cat /soft/nginx/html/conf/zabbix.conf.php
<?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '3306'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = 'zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = 'localhost'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = ''; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
转载于:https://blog.51cto.com/budeed/1926800