zabbix4.2 安装配置过程所遇问题解决

2 篇文章 0 订阅
1 篇文章 0 订阅

目录

背景:

问题1描述:

原因:

解决:

问题2描述:

原因:

解决:

问题3描述:

原因:  

解决:

问题4描述:

原因:

解决:

问题5描述:

原因:

解决:

问题6描述:

原因:

解决:

问题7描述:

原因:

解决:

问题8描述:

原因:

解决:

问题9描述:

原因:

解决:

参考:



写在前面:不建议使用官网教程在Centos6 安装Zabbix4.2

背景:

在以下环境安装 zabbix 4.2(参考官网教程

OS:CentOS release 6.10 (Final) ;

httpd :Server version: Apache/2.2.15 (Unix)

PHP:5.3 (由于不支持zabbix4.2 ,将PHP5.4以上版本)

启动 zabbix-server   zabbix-agent   httpd  三个服务后 访问 http://ip:port/zabbix/ 

 

问题1描述:

  • 页面提示如下错误 (500)

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Apache/2.2.15 (CentOS) Server at 172.16.18.36 Port 8080

  • error_log日志显示:

[crit] [client 172.16.10.193] configuration error:  couldn't perform authentication. AuthType not set!: /zabbix/

原因:

Apache httpd 服务器不同版本的权限设置问题

解决:

打开配置文件,

# vim /etc/zabbix/zabbix_server.conf     

注释掉第三行(以标红)

7 <Directory "/usr/share/zabbix">
8     Options FollowSymLinks
9     AllowOverride None
10    #Require all granted                

因为该环境的httpd版本是 2.2 小于2.4 ,大于等于2.4的版本使用上述语句。

重启服务器 :

#service httpd restart

 

问题2描述:

  • 页面显示:(403 Forbidden)

Forbidden

You don't have permission to access /zabbix/ on this server.


Apache/2.2.15 (CentOS) Server at 172.16.18.36 Port 8080

  • error_log日志显示:

[error] [client 172.16.10.193] Directory index forbidden by Options directive: /usr/share/zabbix/

原因:

/etc/httpd/conf.d  目录下缺少 php.conf 文件

解决:

在/etc/httpd/conf.d  目录下 添加

php.conf 文件,内容为

#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

#
# Allow php to handle Multiviews
#
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following lines to allow PHP to pretty-print .phps
# files as PHP source code:
#
#<FilesMatch \.phps$>
#    SetHandler application/x-httpd-php-source
#</FilesMatch>

#
# Apache specific PHP configuration options
# those can be override in each configured vhost
#
php_value session.save_handler "files"
php_value session.save_path    "/var/lib/php/session"

 

问题3描述:

打开网页无法正常显示

httpd日志显示:Parse error: syntax error, unexpected '['  ****    in /usr/share/zabbix/index.php on line 29

原因:  

php版不支持,Zabbix 3.0 以上的版本需要   PHP 5.4.0以上版本支持 

PHP5.4.0 or later

解决:

卸载原装php安装新的php,具体安装方法参考下面的问题3参考。

 

问题4描述:

运行#service httpd restart

出现:

Starting httpd: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:
Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
                                                           [FAILED]

原因:

php 版本不匹配

解决:

修改 /etc/httpd/conf/httpd.conf   文件    ;  

添加   LoadModule php5_module modules/libphp5.so 

 

问题5描述:

运行网页无法打开,

打开httpd日志 (# tail   /var/log/httpd/error_log) 显示如下错误

PHP Fatal error:  Call to undefined function bccomp() in /usr/share/zabbix/include/classes/setup/CFrontendSetup.php on line 122

原因:

php 不支持,需安装更新包

解决:

安装 php-bcmath  、 php-mbstring, 重启 httpd 服务

# yum  -y  install  php-bcmath 

# yum  -y  install  php-mbstring 

# service httpd restart

 

问题6描述:

  • 打开网页显示:404

Not Found

The requested URL /zabbix/ was not found on this server.


Apache/2.2.15 (CentOS) Server at 172.16.18.36 Port 80

  • httpd日志显示:

[error] [client 172.16.10.193] File does not exist: /var/www/html/zabbix

原因:

/etc/httpd/conf.d  目录下缺少 zabbix.conf (zabbix的配置)文件

解决:

从/usr/share/doc/zabbix-web-4.2.1/ 目标下复制 httpd22-example.conf (因为环境的httpd的版本是2.2 ,如果是2.4 复制httpd24-example.conf)文件到 /etc/httpd/conf.d   ;

修改 时区:php_value date.timezone Asia/ShangHai

重启httpd服务;

#cp /usr/share/doc/zabbix-web-4.2.1/httpd22-example.conf  /etc/httpd/conf.d/ 

#vim  /etc/httpd/conf.d/httpd22-example.conf

#service httpd restart

如果没有找到httpd22-example.conf文件,在/etc/httpd/conf.d/ 目录建立  zabbix.conf (适用于httpd2.2版本) 文件 内容如下:

#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/ShangHai
    </IfModule>
</Directory>

<Directory "/usr/share/zabbix/conf">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>

<Directory "/usr/share/zabbix/app">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>

<Directory "/usr/share/zabbix/include">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>

<Directory "/usr/share/zabbix/local">
    Order deny,allow
    Deny from all
    <files *.php>
        Order deny,allow
        Deny from all
    </files>
</Directory>

这里附录httpd 2.4需要的zabbix.conf 文件内容。

#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/ShangHai
    </IfModule>
</Directory>

<Directory "/usr/share/zabbix/conf">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/app">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/include">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/local">
    Require all denied
</Directory>

 

 

 

问题7描述:

打开网页无法正常显示,乱码如下:

[T_ZBX_STR, O_NO,    null,    null,    'isset({enter}) && {enter} != "'.ZBX_GUEST_USER.'"', _('Username')], 'password' =>    [T_ZBX_STR, O_OPT, null,    null,    'isset({enter}) && {enter} != "'.ZBX_GUEST_USER.'"'], 'sessionid' =>    [T_ZBX_STR, O_OPT, null,    null,    null], 'reconnect' =>    [T_ZBX_INT, O_OPT, P_SYS,    null,    null], 'enter' =>    [T_ZBX_STR, O_OPT, P_SYS,    null,    null], 'autologin' =>    [T_ZBX_INT, O_OPT, null,    null,    null], 'request' =>    [T_ZBX_STR, O_OPT, null,    null,    null], 'form' =>    [T_ZBX_STR, O_OPT, null,    null, null] ]; check_fields($fields); if (hasRequest('reconnect') && CWebUser::isLoggedIn()) { CWebUser::logout(); } $config = select_config(); $autologin = hasRequest('enter') ? getRequest('autologin', 0) : getRequest('autologin', 1); $request = getRequest('request', ''); if ($request) { $test_request = []; preg_match('/^\/?(?[a-z0-9\_\.]+\.php)(?\?.*)?$/i', $request, $test_request); $request = (array_key_exists('filename', $test_request) && file_exists('./'.$test_request['filename'])) ? $test_request['filename'].(array_key_exists('request', $test_request) ? $test_request['request'] : '') : ''; } if (!hasRequest('form') && $config['http_auth_enabled'] == ZBX_AUTH_HTTP_ENABLED && $config['http_login_form'] == ZBX_AUTH_FORM_HTTP && !hasRequest('enter')) { redirect('index_http.php'); exit; } // login via form if (hasRequest('enter') && CWebUser::login(getRequest('name', ZBX_GUEST_USER), getRequest('password', ''))) { if (CWebUser::$data['autologin'] != $autologin) { API::User()->update([ 'userid' => CWebUser::$data['userid'], 'autologin' => $autologin ]); } $redirect = array_filter([CWebUser::isGuest() ? '' : $request, CWebUser::$data['url'], ZBX_DEFAULT_URL]); redirect(reset($redirect)); exit; } if (CWebUser::isLoggedIn() && !CWebUser::isGuest()) { redirect(CWebUser::$data['url'] ? CWebUser::$data['url'] : ZBX_DEFAULT_URL); } $messages = clear_messages(); (new CView('general.login', [ 'http_login_url' => $config['http_auth_enabled'] == ZBX_AUTH_HTTP_ENABLED ? (new CUrl('index_http.php'))->setArgument('request', getRequest('request')) : '', 'guest_login_url' => CWebUser::isGuestAllowed() ? (new CUrl())->setArgument('enter', ZBX_GUEST_USER) : '', 'autologin' => $autologin == 1, 'error' => hasRequest('enter') && $messages ? array_pop($messages) : null ])) ->disableJsLoader() ->render();

原因:

查看/etc/httpd/conf.d 目录下的 php.conf 文件 的如下两项是否被注释掉,如果没有则添加

#php_value session.save_handler "files"
#php_value session.save_path    "/var/lib/php/session"

解决:

将/etc/httpd/conf.d 目录下的 php.conf 文件 的 最后两行的注释去掉,如果没有则添加如下两项。

php_value session.save_handler "files"
php_value session.save_path    "/var/lib/php/session"

也可能是缺少php 组件,安装 php-bcmath  、 php-mbstring 

 

问题8描述:

打开网页,设置过程显示:

Check of pre-requisites

  • PHP xmlwriter extension missing.
  • PHP xmlreader extension missing.

原因:

php 组件不支持需安装

解决:

安装 php-xmlwriter

#yum install php-xmlwriter

 

问题9描述:

配置zabbix Web界面的Mysql端口和密码,页面出现如下错误提示:

Error connecting to database: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

原因:

安装的Mysql 是8.0以上版本,使用的新的鉴权插件‘caching_sha2_password’与zabbix的mysql客户端程序的鉴权插件不一样。

解决:

使用 mysql_native_password 鉴权插件,用root用户登录mysql,执行如下命令:

ALTER USER 'zabbix_username’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘zabbix_password’;


参考:

问题1参考:

https://stackoverflow.com/questions/21265191/apache-authtype-not-set-500-error

https://boinc.berkeley.edu/dev/forum_thread.php?id=8603

问题3参考:

https://support.zabbix.com/browse/ZBX-11009    

centos6升级php5.4以上版本:
卸载原版本: https://blog.csdn.net/dc_726/article/details/9519293

升级新版本:https://www.tecmint.com/install-php-5-4-php-5-5-or-php-5-6-on-centos-6/

问题4参考:

https://talk.plesk.com/threads/solved-latest-php-5-3-26-yum-update-from-art-breaks-apache.287767/

问题5参考:

https://bugs.launchpad.net/ubuntu/+source/zabbix/+bug/1673462

问题8参考:

https://stackoverflow.com/questions/6384979/how-to-enable-xmlwriter-after-php-having-been-compiled

问题9参考:

https://tableplus.io/blog/2018/07/failed-to-load-caching-sha2-password-authentication-plugin-solved.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值