PHP 未被 Zabbix 前端的 proxy_fcgi 和 php_fpm 执行

PHP 未被 Zabbix 前端的 proxy_fcgi 和 php_fpm 执行

我已经安装了 php7.0-fpm 并为 Zabbix 前端启用了 proxy_fcgi 模式。

但是,当我尝试从任何页面访问时,我得到的是该页面的 PHP 源代码,而不是普通页面。

我的配置如下:

/etc/php/7.0/fpm/pool.d/www.conf
[www]
user= www-data
group = www-data
listen = /run/php/php7.0-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children=10
pm.start_servers =5
pm.min_spare_servers = 2
pm.max_spare_servers = 7
chdir = /usr/share/zabbix/

/etc/apache2/sites-enabled/zabbix.conf 
<VirtualHost *:80>
    Include conf-available/zabbix.conf
    <FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost/usr/share/zabbix/"
    </FilesMatch>
</VirtualHost>

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_worker_module (shared)
 negotiation_module (shared)
 proxy_module (shared)
 proxy_fcgi_module (shared)
 setenvif_module (shared)
 status_module (shared)

我在访问任何页面时仅获取 php 源代码:

<?php
/*
** Zabbix
** Copyright (C) 2001-2017 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/

require_once dirname(__FILE__).'/include/config.inc.php';

日志中一切都很清楚,没有任何错误。

能否请你帮忙?

答案1

已改变。看起来您的配置文件中有错误,只需输入SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"而不是SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost/usr/share/zabbix/"

我在我的虚拟机上检查了它,一切正常。

相关内容