CentOS 6.8下Zabbix Server 安装部署详细步骤

CentOS 6.8下Zabbix Server 安装部署详细步骤
所需要的环境:apache php mysql
这里apache和mysql已经预先装好了,具体安装请参见apache和mysql的安装方法
因为装php的时候遇到了很多问题
可能步骤会有些乱
1.准备zabbix的源码包
zabbix-2.4.8.tar.gz
这里用的是2.4.8版本
解压
[root@linux1 ~]# tar -zxvf zabbix-2.4.8.tar.gz
[root@linux1 ~]# cd zabbix-2.4.8
2.新建用户组
[root@linux1 ~]# groupadd zabbix
[root@linux1 ~]#  useradd -g zabbix zabbix
3.zabbix数据库创建导入
mysql> create database zabbix character set utf8;
mysql> use zabbix
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";
mysql> flush privileges;
mysql> source /root/zabbix-2.4.8/database/mysql/schema.sql
mysql> source /root/zabbix-2.4.8/database/mysql/images.sql
mysql> source /root/zabbix-2.4.8/database/mysql/data.sql
4.编译安装zabbix
[root@linux1 ~]# cd zabbix-2.4.8
[root@linux1 zabbix-2.4.8]# ./configure --prefix=/usr/local/zabbix --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy
可能会缺少一些包,查看一下报错,用yum安装即可
[root@linux1 zabbix-2.4.8]# make
[root@linux1 zabbix-2.4.8]# make install
 
5.添加服务端口
[root@linux1 zabbix-2.4.8]# vim /etc/services
zabbix-agent 10050/tcp    # Zabbix Agent
zabbix-agent 10050/udp   # Zabbix Agent
zabbix-trapper 10051/tcp   # Zabbix Trapper
zabbix-trapper 10051/udp  # Zabbix Trapper
 
6.修改zabbix配置文件
[root@linux1 ~]# cd /usr/local/zabbix/etc
[root@linux1 ~]# vim zabbix_server.conf
DBName=zabbix  #数据库名称
DBUser=zabbix  #数据库用户名
DBPassword=zabbix #数据库密码
DBPort=3306 #我机器数据库端口是3306
DBSocket=/tmp/mysql.sock
ListenIP=192.168.1.120  #数据库ip地址
7.设置启动脚本
zabbix默认的启动脚本在 /usr/local/zabbix/sbin/ 下
[root@linux1 ~]# cp /usr/local/zabbix/sbin/zabbix_server /etc/init.d/zabbix_server
[root@linux1 ~]# cp /usr/local/zabbix/sbin/zabbix_agentd /etc/init.d/zabbix_agentd
[root@linux1 ~]# chkconfig zabbix_server on          #添加开机启动
[root@linux1 ~]# chkconfig zabbix_agentd on  #添加开机启动
8.设置zabbix的web站点
[root@linux1 ~]# mkdir /usr/local/apache/zabbix
[root@linux1 ~]# cp /root/zabbix-2.4.8/frontends/php/* /usr/local/apache/zabbix/
修改apache的配置文件
[root@linux1 ~]# vim /usr/local/apache2/conf/httpd.conf
Alias /zabbix /usr/local/apache2/zabbix
<Directory /usr/local/apache2/zabbix>
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html  index.php          在这后面添加  index.php 
</IfModule>
在这两行后面
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
9.下载php源码包
php-5.6.29.tar.gz
解压
[root@linux1 ~]# tar -zxvf php-5.6.29.tar.gz
10.编译安装php
[root@linux1 ~]# cd php-5.6.29
[root@linux1 php-5.6.29]# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-bcmath \
--enable-sockets \
--with-libxml-dir \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--with-gettext \
--enable-mbstring \
--with-mcrypt \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-zip \
--with-bz2 \
--enable-soap \
--with-pear \
--with-pcre-dir \
--with-openssl \
--with-config-file-path=/usr/local/php/etc \
--enable-shmop \
--enable-intl \
这中间可能会缺少很多包,报错解决办法参见
PHP编译安装时常见错误解决办法
 
http://www.linuxidc.com/Linux/2016-12/138909.htm
 
 
[root@linux1 php-5.6.29]# make
[root@linux1 php-5.6.29]#make install
11.测试一下apache是否可以解析php (这一步没有问题可以不做,因为当时在这里卡了很久)
在 /usr/local/apache2/htdocs/ 新建一个php页面
[root@linux1 htdocs]# vi info.php
<?php
phpinfo();
?>;
重启一下apache
[root@linux1 htdocs]# service httpd restart
用浏览器打开 192.168.1.120/info.php
CentOS 6.8下Zabbix Server 安装部署详细步骤
出现上面的界面说明可以运行php,同时这里也能看到php的具体配置信息
*我在这里遇到的问题
apache无法解析php,原因是apache中没有加载 libphp5.so 模块,
这个模块是在编译安装php时就应该导入进apache,配置命令如下
--with-apxs2=/usr/local/apache2/bin/apxs
但是结果apache中并没有 libphp5.so 模块,不知道是什么原因
起初我编译的是php5.5,找不出原因之后我才重新下载了5.6版本进行编译安装
发现libphp5.so导入成功,apache可以运行php
 
12.修改php.ini
[root@linux1 ~]# vi /usr/local/php/etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time= 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
mbstring.func_overload = 0
always_populate_raw_post_data = -1
**参照官方文档**
Pre-requisiteMinimum valueDescription
PHP version
5.3.0
PHP memory_limit option
128MB
In php.ini:
memory_limit = 128M
PHP post_max_size option
16MB
In php.ini:
post_max_size = 16M
PHP upload_max_filesize option
2MB
In php.ini:
upload_max_filesize = 2M
PHP max_execution_time option
300 seconds
In php.ini:
max_execution_time = 300
PHP max_input_time option
300 seconds
In php.ini:
max_input_time = 300
PHP session.auto_start option
must be disabled
In php.ini:
session.auto_start = 0.
Database support
One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite
One of the following modules must be installed:
ibm_db2, mysql, oci8, pgsql, sqlite3
bcmath
php-bcmath
mbstring
php-mbstring
PHP mbstring.func_overload option
must be disabled
In php.ini:
mbstring.func_overload = 0.
PHP always_populate_raw_post_data option
must be set to -1Required only for PHP versions 5.6.0 or newer.
In php.ini:
always_populate_raw_post_data = -1
sockets
php-net-socket. Required for user script support.
gd
2.0 or higher
php-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).
libxml
2.6.15
php-xml or php5-dom
xmlwriter
php-xmlwriter
xmlreader
php-xmlreader
ctype
php-ctype
session
php-session
gettext
php-gettext
Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available.
然后按官方手册,mbstring.func_overload 必须关闭,lways_populate_raw_post_data option必须设为1

相关推荐