编译安装zabbix3.2.5-LNMP

编译安装zabbix3.2.5-LNMP
1.1 环境准备
系统环境准备:
redhat 6.8 64位
mysql-5.6.29
php-5.5.38
zabbix-3.2.5


安装zabbix用到的安装包
[root@zabbix-server ~]# ls
anaconda-ks.cfg     libiconv-1.14.tar.gz    mysql-5.6.29.tar.gz  xcache-3.2.0.tar.gz
cmake-2.8.8.tar.gz  libmcrypt-2.5.8.tar.gz  nginx-1.8.1.tar.gz   zabbix-3.2.5.tar.gz        
mcrypt-2.6.8.tar.gz mhash-0.9.9.9.tar.gz    php-5.5.38.tar.xz
配置前先关闭iptables和SELINUX,避免安装过程中报错。
# service iptables stop
# setenforce 0
# vi /etc/sysconfig/selinux


SELINUX=disabled
zabbix3.2.0对环境的要求 :
MySQL 5.1以上最好是 5.6或者更高的版本
PHP 5.4或者更高的版本
1.2 LNMP安装
1.2.1 编译安装nginx
安装nginx, PHP, MySQL以及php连接mysql库组件。
安装nginx时必须先安装相应的编译工具
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel  openssl openssl-devel pcre-devel


建立nginx 组
groupadd -r nginx
useradd -g nginx -M -s /sbin/nologin -r nginx
id nginx


zlib:nginx提供gzip模块,需要zlib库支持
openssl:nginx提供ssl功能
pcre:支持地址重写rewrite功能


下载安装包


wget http://nginx.org/download/nginx-1.8.1.tar.gz




编译安装
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-threads


make && make install


nginx启动脚本


官方文档:http://wiki.nginx.org/RedHatNginxInitScript


Should work on RHEL, Fedora, CentOS. Tested on CentOS 5.


Save this file as /etc/init.d/nginx


#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid


# Source function library.
. /etc/rc.d/init.d/functions


# Source networking configuration.
. /etc/sysconfig/network


# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0


nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)


NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"


[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx


lockfile=/var/lock/subsys/nginx


make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -n "$user" ]; then
      if [ -z "`grep $user /etc/passwd`" ]; then
         useradd -M -s /bin/nologin $user
      fi
      options=`$nginx -V 2>&1 | grep 'configure arguments:'`
      for opt in $options; do
          if [ `echo $opt | grep '.*-temp-path'` ]; then
              value=`echo $opt | cut -d "=" -f 2`
              if [ ! -d "$value" ]; then
                  # echo "creating" $value
                  mkdir -p $value && chown -R $user $value
              fi
          fi
       done
    fi
}


start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}


stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}


restart() {
    configtest || return $?
    stop
    sleep 1
    start
}


reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}


force_reload() {
    restart
}


configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}


rh_status() {
    status $prog
}


rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac




chmod +x  /etc/init.d/nginx   ###给/etc/init.d/nginx执行权限


启动nginx


service nginx start
Starting nginx (via systemctl):                            [  确定  ]


service nginx status
● nginx.service - SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
   Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled)
   Active: active (running) since 六 2017-02-18 22:33:36 CST; 3min 50s ago
     Docs: man:systemd-sysv-generator(8)
 Main PID: 16029 (nginx)
   CGroup: /system.slice/nginx.service
           ├─16029 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           └─16031 nginx: worker process


2月 18 22:33:36 nginx2 systemd[1]: Starting SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse pro...r...
2月 18 22:33:36 nginx2 nginx[15909]: Starting nginx: [  确定  ]
2月 18 22:33:36 nginx2 systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
2月 18 22:33:36 nginx2 systemd[1]: Started SYSV: NGINX is an HTTP(S) server, HTTP(S) reverse prox...ver.
Hint: Some lines were ellipsized, use -l to show in full.


开机启动nginx
ckconfig --add nginx
chkconfig  nginx on 




登陆页面
Welcome to nginx!


If you see this page, the nginx web server is successfully installed and working. Further configuration is required.


For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.


Thank you for using nginx.


nginx安装完成
 
 
1.2.2 编译安装mysql5.6
安装编译源码所需的工具和库
 
yum -y install ncurses-devel 


tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure 
gmake
gmake install
cd ../
 
编译安装:


groupadd mysql  
useradd  -g mysql mysql  -s /sbin/nologin
tar -xf mysql-5.6.29.tar.gz
cd mysql-5.6.29
cmake  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=system \
-DMYSQL_TCP_PORT=3306 \
-DWITH_SSL=bundled
 
 
注:重新运行配置,需要删除CMakeCache.txt文件
rm -f CMakeCache.txt 
make
make install
 
修改mysql安装目录
chown -R mysql:mysql /usr/local/mysql


修改mysql数据库文件目录


chown -R mysql:mysql /usr/local/mysql/data
 
初始化配置
进入安装路径
# cd /usr/local/mysql
进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf"
注意:若在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。
在使用"yum update"更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,将它重命名成别的。否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题。
复制mysql服务启动配置文件
# mv /etc/my.cnf /etc/my.cnf.bak
# cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf
vim  /usr/local/mysql/my.cnf
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket = /tmp/mysql.sock
 
启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld


basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
mysqld_pid_file_path=/usr/local/mysql/data/zabbix-server.pid


设置开机启动
chkconfig mysqld on 




service mysqld start
或者
./mysqld_safe --defaults-file=/usr/local/mysql/my.cnf


添加库文件
echo "/usr/local/mysql/lib" >>/etc/ld.so.conf
ldconfig


配置用户
MySQL启动成功后,root默认没有密码,我们需要设置root密码。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
修改/etc/profile文件,在文件末尾添加
echo 'declare -x PATH="/usr/local/mysql/bin:$PATH"' >> /etc/profile
让配置立即生效
source /etc/profile
修改数据库的root密码:
mysql -uroot  


mysql> SET PASSWORD = PASSWORD('123abc');
或是
 
# mysqladmin -uroot -p password 123abc
Enter password:        这里直接回车
Warning: Using a password on the command line interface can be insecure.


若要设置root用户可以远程访问,执行


mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;


红色的password为远程访问时,root用户的密码,可以和本地不同。
 
 
配置防火墙
防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口
打开/etc/sysconfig/iptables文件,在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT
然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:
 service iptables restart 
OK,一切配置完毕,你可以访问你的MySQL了~
1.2.3编译安装PHP5.6
添加依赖应用
 
yum install -y gcc \
gcc-c++ \
autoconf \
libjpeg \
libjpeg-devel \
libpng \
libpng-devel \
freetype \
freetype-devel \
libpng \
libpng-devel \
libxml2 \
libxml2-devel \
zlib \
zlib-devel \
glibc \
glibc-devel \
glib2 \
glib2-devel \
bzip2 \
bzip2-devel \
ncurses \
curl \
openssl-devel \
db4-devel \
libXpm-devel \
libX11-devel \
gmp-devel \
readline-devel \
libxslt-devel \
expat-devel \
xmlrpc-c \
libcurl \
libcurl-devel 
 
 
安装加密扩展库,先安装Libmcrypt
 
tar zxvf libmcrypt-2.5.8.tar.gz 
cd libmcrypt-2.5.8
./configure
make
make install
 
 
编译安装
xz -d php-5.5.38.tar.xz
tar xf php-5.5.38.tar
cd php-5.5.38/


./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-inline-optimization \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-fpm \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir  \
--with-freetype-dir \
--enable-gd-native-ttf \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--disable-mbregex \
--disable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-pdo-mysql \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir  \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear


或者




./configure \
--prefix=/usr/local/php-5.5.38 \
--with-config-file-path=/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-iconv-dir=/usr/local/libiconv \
--with-config-file-scan-dir=/etc/php.d \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib    \
--with-gettext \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-opcache=no \
--enable-ftp 


make
make test
make install
php配置
php.ini是php运行核心配置文件
php-fpm.conf是php-fpm进程服务的配置文件
 
cd php-5.6.28
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
 
 
 
fpm测试php配置
# /usr/local/php/sbin/php-fpm -t


[23-May-2016 20:03:52] NOTICE: 


configuration file /usr/local/php/etc/php-fpm.conf test is successful
 
 
添加到server里管理启动:
 
# chkconfig --add php-fpm


# chkconfig php-fpm on


# service php-fpm start
Starting php-fpm  done


netstat –anpt
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      705/php-fpm
 
 
修改PHP默认端口:
vi /usr/local/php/etc/php-fpm.conf


listen = 127.0.0.1:8000
 
整合nginx和php5




编辑/etc/nginx/nginx.conf,启用如下选项:




 if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php$1 last;
        }
      
        location ~ .*\.php(\/.*)*$
        {


           set $path_info "";
           set $real_script_name $fastcgi_script_name;
           if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
            }
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
           }




并在所支持的主页面格式中添加php格式的主页,类似如下:
location / {
            root   html;
            index  index.php index.html index.htm;
        }
        
而后重新载入nginx的配置文件:
# nginx -s reload




3、在/usr/html新建index.php的测试页面,测试php是否能正常工作:
# cat > /usr/html/index.php << EOF
phpinfo();
?>
接着就可以通过浏览器访问此测试页面了。


安装xcache,为php加速:




安装
tar xf xcache-3.2.0.tar.gz
cd xcache-3.2.0
/usr/local/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
make && make install




安装结束时,会出现类似如下行:
Installing shared extensions:     /usr/local/php-5.5.38/lib/php/extensions/no-debug-non-zts


编辑php.ini,整合php和xcache:




首先将xcache提供的样例配置导入php.ini
# mkdir /etc/php.d
# cp xcache.ini /etc/php.d




说明:xcache.ini文件在xcache的源码目录中。




接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:


extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so


注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。




重新启动php-fpm
# service php-fpm restart




 
2.1 下载zabbix源码包
官网:http://www.zabbix.com/download.php
下载zabbix-3.2.1.tar.gz
安装zabbix所需的组件(server,agent) 
yum -y install curl libcurl-devel net-snmp net-snmp-devel perl-DBI  gcc gcc++ make libxml2 libxml2-devel  
 
server: (172.28.3.103)服务端
创建zabbix用户组与用户:
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
tar xzvf zabbix-3.2.5.tar.gz 
编译安装:
cd zabbix-3.2.5
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-ipv6


make && make install 
 
创建数据库和授权用户
说明:数据文件导入的顺序不能变,也可以在命令行使用mysql命令导入数据文件
 
[root@test ~]# service mysqld start


mysql> create database zabbix character set utf8;


mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123456';


mysql> flush privileges;
 
 
 
导入数据库sql脚本:
# cd zabbix-3.2.1
在解压的zabbix目录下,将database/mysql目录下三个sql文件导入到zabbix数据库里。(下面用的是zabbix用户来导入文件,这个用户在数据库是默认存在的)
# mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql


# mysql -uzabbix -p123456 zabbix < database/mysql/images.sql


# mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
或是
# mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql


# mysql -uzabbix -p123456 zabbix < database/mysql/images.sql


# mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
修改配置文件并启动
mkdir -p /usr/local/nginx/html


cp -R frontends/php /usr/local/nginx/html/zabbix


chown -R nginx.nginx /usr/local/nginx/html/zabbix
 
修改过滤掉注释的名字
cat /usr/local/zabbix-server/etc/zabbix_server.conf |grep -v "^#" |grep -v "^$" > /usr/local/zabbix-server/etc/zabbix_server.conf.back
我们只需要关注DBHost、DBName、DBUser、DBPassword几项即可。这几项是配置zabbix server连接mysql数据库的参数。
 
vim /usr/local/zabbix-server/etc/zabbix_server.conf


LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
 
创建日志文件存放位置:
mkdir /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix
启动zabbix服务:
/usr/local/zabbix-server/sbin/zabbix_server
 
用server来管理启动zabbix服务:
 
# cd zabbix-3.2.5
# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/


修改zabbix_server的启动脚本
# vim /etc/init.d/zabbix_server
# Edit these to match your system settings


        # Zabbix-Directory
        BASEDIR=/usr/local/zabbix-server

# chkconfig --add zabbix_server
# chkconfig zabbix_server on




创建软链接:


ln -sv  /usr/local/zabbix-server/sbin/zabbix_server /usr/local/sbin/


启动服务:


service zabbix_server start
 
agent:  (172.28.3.100)客户端
创建zabbix用户组与用户:
# groupadd zabbix
# useradd -g zabbix -s /sbin/nologin zabbix 
编译安装:
 
# cd zabbix-3.2.5


# ./configure --prefix=/usr/local/zabbix-agent  --enable-agent


make && make install


 


# cd /usr/local/zabbix-agent


# vi etc/zabbix_agentd.conf


LogFile=/var/log/zabbix/zabbix_agentd.log


Server=172.28.3.103


ServerActive=172.28.3.103


Hostname=172.28.3.100
 
用server来管理启动zabbix服务:
 
# cd zabbix-3.2.1


# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/


# chkconfig --add zabbix_agentd


# chkconfig zabbix_agentd on


创建软链接:


# ln -s /usr/local/zabbix/sbin/zabbix_agentd/usr/local/sbin/ 


启动服务:


service zabbix_agentd start
 


注:若要服务器端也安装客户端相关参数可以参考:http://meiling.blog.51cto.com/6220221/1339389
2.3 配置zabbix web页面
server {
        listen       80;
        server_name  10.1.1.7 localhost;
        root /usr/local/nginx/html/zabbix;
        charset utf-8;
        index  index.php index.html index.htm;
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php$1 last;
        }


        location ~ .*\.php(\/.*)*$
        {


           set $path_info "";
           set $real_script_name $fastcgi_script_name;
           if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
            }
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
           }
    }
 


 
其中/etc/php.ini date.timezone Asia/Shanghai主要是定义php的时区。
 
最后重启nginx,zabbix服务,如下:
nginx -s reload
services zabbix_server restart
然后访问http://10.1.1.7/zabbix/setup.php这个地址,如下进行安装:
 
 
 
 
 
 
完成后即可登录:zabbix默认的用户名和密码是Admin/zabbix
 
 
如果创建zabbix.conf.php文件这一步有报错话,可以手动下载好那个文件在相应目录创建zabbix.conf.php文件复制里面的内容即可:
 
vi /var/www/zabbix/php/conf/zabbix.conf.php




// Zabbix GUI configuration file.


global $DB;


 


$DB['TYPE']     = 'MYSQL';


$DB['SERVER']   = '10.1.1.7';


$DB['PORT']     = '3306';


$DB['DATABASE'] = 'zabbix';


$DB['USER']     = 'zabbix';


$DB['PASSWORD'] = 'zabbix';


 


// Schema name. Used for IBM DB2 and PostgreSQL.


$DB['SCHEMA'] = '';


 


$ZBX_SERVER      = '10.1.1.7';


$ZBX_SERVER_PORT = '10051';


$ZBX_SERVER_NAME = '';


 


$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
 


正常安装完zabbix后,登录后zabbix监控报错zabbix server is not running: the information displayed may not be current,




根据日志报错排查
cat /var/log/zabbix/zabbix_server.log 


zabbix进程查看
ps aux |grep zabbix 


查看监听zabbix server---------zabbix agent    10050---10051端口 
netstat -nplut |grep zabbix


登陆报错解决    zabbix server is running | No.


解决方法1


setsebool -P httpd_can_network_connect on   selinux 允许它通过httpd服务


关闭selinux


永久关闭vi /etc/selinux/config


#SELINUX=disabled


#SELINUXTYPE=targeted


临时关闭 setenforce 0  


关闭防火墙


永久关闭 chkconfig iptables off


临时生效 iptables -F


解决方法2


cd /usr/local/nginx/html/zabbix/


修改配置文件


vi zabbix.conf.php


修改lochlhost为 自己服务器的IP地址


修改$DB['SERVER']   = '192.168.30.6';


修改$ZBX_SERVER     = '192.168.30.6';


解决办法3
检查 /usr/local/zabbix-server/conf/zabbix-server.conf配置文件
查看里面数据库有没有配置好导致zabbix-server启动后,10051端口没有




重启服务


service httpd restart


service zabbix_agentd restart


service zabbix_server restart

你可能感兴趣的:(Zabbix)