我正在尝试让一个名为 OpenFISMA 的程序在 AWS 中的 Ubuntu AMI 上运行。该应用程序并不是在 Ubuntu 平台上真正编码的,但我在我的舒适区中,并尝试了 CentOS 和 OpenSUSE(两者都是该应用程序的“原生”),以获得相同或更差的结果。那么,为什么不让它在 Ubuntu 上运行呢?无论如何,该应用程序可以在这里找到:www.openfisma.org,并且可以在这里找到安装指南:https://openfisma.atlassian.net/wiki/display/030100/Installation+Guide安装指南有点糟糕。它没有以任何连贯的方式列出依赖关系,也没有提供任何细节(甚至没有在整个页面上提到一次 Zend),因此我做了很多工作来推测我所拥有的信息。此页面提供了一些依赖项信息(不过,Zend 一次也没有被提及): https://openfisma.atlassian.net/wiki/display/PUBLIC/RPM+Management#RPMManagement-BasicOverviewofRPMPackages
无论如何,我完成了安装(到目前为止我可以重建它)。我将第一次进入登录页面,当我加载页面时应该会发生某种引导。 (我不是程序员,所以我不知道它在那里做什么。)无论如何,我在网页上收到一条消息:“引导应用程序时发生异常。”
所以,然后我去查看 /var/www/data/logs/php.log 并找到以下消息:
[22-Oct-2013 17:29:18 UTC] PHP Fatal error: Uncaught exception 'Zend_Exception' with message 'No entry is registered for key 'Zend_Log'' in /var/www/library/Zend/Registry.php:147
Stack trace:
#0 /var/www/public/index.php(188): Zend_Registry::get('Zend_Log')
#1 {main}
thrown in /var/www/library/Zend/Registry.php on line 147
每次加载页面时都会发生这种情况。我发现存在与在 Zend 注册表中注册 Zend_Log 变量相关的问题,但除此之外我真的不知道该怎么办。我是否缺少它需要的包,或者该应用程序是否未编码以正确注册变量?我不知道。非常感谢任何帮助。下面包含日志消息 (index.php) 中引用的应用程序文件。
<?php
/**
* Copyright (c) 2008 Endeavor Systems, Inc.
*
* This file is part of OpenFISMA.
*
* OpenFISMA 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 3 of the License, or (at your option) any later
* version.
*
* OpenFISMA 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 OpenFISMA. If not, see
* {@link http://www.gnu.org/licenses/}.
*/
try {
defined('APPLICATION_PATH')
|| define(
'APPLICATION_PATH',
realpath(dirname(__FILE__) . '/../application')
);
// Define application environment
defined('APPLICATION_ENV')
|| define(
'APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')
);
set_include_path(
APPLICATION_PATH . '/../library/Symfony/Components' . PATH_SEPARATOR .
APPLICATION_PATH . '/../library' . PATH_SEPARATOR .
get_include_path()
);
require_once 'Fisma.php';
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/application.ini'
);
Fisma::setAppConfig($application->getOptions());
Fisma::initialize(Fisma::RUN_MODE_WEB_APP);
$application->bootstrap()->run();
} catch (Zend_Config_Exception $zce) {
// A zend config exception indicates that the application may not be installed properly
echo '<h1>The application is not installed correctly</h1>';
$zceMsg = $zce->getMessage();
if (stristr($zceMsg, 'parse_ini_file') !== false) {
if (stristr($zceMsg, 'application.ini') !== false) {
if (stristr($zceMsg, 'No such file or directory') !== false) {
echo 'The ' . APPLICATION_PATH . '/config/application.ini file is missing.';
} elseif (stristr($zceMsg, 'Permission denied') !== false) {
echo 'The ' . APPLICATION_PATH . '/config/application.ini file does not have the ' .
'appropriate permissions set for the application to read it.';
} else {
echo 'An ini-parsing error has occured in ' . APPLICATION_PATH . '/config/application.ini ' .
'<br/>Please check this file and make sure everything is setup correctly.';
}
} else if (stristr($zceMsg, 'database.ini') !== false) {
if (stristr($zceMsg, 'No such file or directory') !== false) {
echo 'The ' . APPLICATION_PATH . '/config/database.ini file is missing.<br/>';
echo 'If you find a database.ini.template file in the config directory, edit this file ' .
'appropriately and rename it to database.ini';
} elseif (stristr($zceMsg, 'Permission denied') !== false) {
echo 'The ' . APPLICATION_PATH . '/config/database.ini file does not have the appropriate ' .
'permissions set for the application to read it.';
} else {
echo 'An ini-parsing error has occured in ' . APPLICATION_PATH . '/config/database.ini ' .
'<br/>Please check this file and make sure everything is setup correctly.';
}
} else {
echo 'An ini-parsing error has occured. <br/>Please check all configuration files and make sure ' .
'everything is setup correctly';
}
} elseif (stristr($zceMsg, 'syntax error') !== false) {
if (stristr($zceMsg, 'application.ini') !== false) {
echo 'There is a syntax error in ' . APPLICATION_PATH . '/config/application.ini ' .
'<br/>Please check this file and make sure everything is setup correctly.';
} elseif (stristr($zceMsg, 'database.ini') !== false) {
echo 'There is a syntax error in ' . APPLICATION_PATH . '/config/database.ini ' .
'<br/>Please check this file and make sure everything is setup correctly.';
} else {
echo 'A syntax error has been reached. <br/>Please check all configuration files and make sure ' .
'everything is setup correctly.';
}
} else {
// Then the exception message says nothing about parse_ini_file nor 'syntax error'
echo 'Please check all configuration files, and ensure all settings are valid.';
}
echo '<br/>For more information and help on installing OpenFISMA, please refer to the ' .
'<a target="_blank" href="http://manual.openfisma.org/display/ADMIN/Installation">' .
'Installation Guide</a>';
} catch (Doctrine_Manager_Exception $dme) {
echo '<h1>An exception occurred while bootstrapping the application.</h1>';
// Does database.ini have valid settings? Or is it the same content as database.ini.template?
$databaseIniFail = false;
$iniData = file(APPLICATION_PATH . '/config/database.ini');
$iniData = str_replace(chr(10), '', $iniData);
if (in_array('db.adapter = ##DB_ADAPTER##', $iniData)) {
$databaseIniFail = true;
}
if (in_array('db.host = ##DB_HOST##', $iniData)) {
$databaseIniFail = true;
}
if (in_array('db.port = ##DB_PORT##', $iniData)) {
$databaseIniFail = true;
}
if (in_array('db.username = ##DB_USER##', $iniData)) {
$databaseIniFail = true;
}
if (in_array('db.password = ##DB_PASS##', $iniData)) {
$databaseIniFail = true;
}
if (in_array('db.schema = ##DB_NAME##', $iniData)) {
$databaseIniFail = true;
}
if ($databaseIniFail) {
echo 'You have not applied the settings in ' . APPLICATION_PATH . '/config/database.ini appropriately. ' .
'Please review the contents of this file and try again.';
} else {
if (Fisma::debug()) {
echo '<p>'
. get_class($dme)
. '</p><p>'
. $dme->getMessage()
. '</p><p>'
. "<p><pre>Stack Trace:\n"
. $dme->getTraceAsString()
. '</pre></p>';
} else {
$logString = get_class($dme)
. "\n"
. $dme->getMessage()
. "\nStack Trace:\n"
. $dme->getTraceAsString()
. "\n";
Zend_Registry::get('Zend_Log')->err($logString);
}
}
} catch (Exception $exception) {
// If a bootstrap exception occurs, that indicates a serious problem, such as a syntax error.
// We won't be able to do anything except display an error.
echo '<h1>An exception occurred while bootstrapping the application.</h1>';
if (Fisma::debug()) {
echo '<p>'
. get_class($exception)
. '</p><p>'
. $exception->getMessage()
. '</p><p>'
. "<p><pre>Stack Trace:\n"
. $exception->getTraceAsString()
. '</pre></p>';
} else {
$logString = get_class($exception)
. "\n"
. $exception->getMessage()
. "\nStack Trace:\n"
. $exception->getTraceAsString()
. "\n";
Zend_Registry::get('Zend_Log')->err($logString);
}
}
我最近在 CentOS 6.5 上遇到了这个问题。关闭 selinux 解决了这个问题。
要测试,您可以尝试:
# setenforce 0
显然关闭 selinux 会带来安全隐患,因此一旦您确认它有效,您可能需要考虑创建一个 selinux 策略以允许 apache 访问 openfisma 目录中的文件。
我遇到了同样的问题,但找到了似乎有效的解决方案,并且允许 selinux 继续设置为强制执行。我运行了以下两个命令,我能够获得登录屏幕。
# semanage fcontext -a -t httpd_sys_rw_content_t "/usr/share/openfisma(/.*?)"
# restorecon -R -v /usr/share/openfisma/
根据我目前对 SELinux 的了解,这会在 /usr/share/openfisma 目录及其下面的任何内容的内容上设置 httpd 读写上下文。 Restorecon 将递归地重置该目录中所有文件的上下文。
编辑:我还发现需要以下命令
# /usr/sbin/setsebool -P httpd_can_network_connect on