[英]PHP Zend Framework: Internal Server Error 500 on localhost when trying to run “Lucene.php” on browser
我正在運行 windows 7 並且我全新安裝了 Zend 框架。 在一個名為“search.php”的新 php 文件上,我正在嘗試使用 Zend_Search_Lucene 構建一個搜索應用程序,第一行是:
<?php require_once "C:...\Zend\Search\Lucene.php";?>
當我運行此代碼時,我在瀏覽器上看到的是內部服務器錯誤 500。然后我發現每當我嘗試自行運行 Zend 庫中的某些文件時都會收到此錯誤,這就是導致我提到的錯誤的原因。 .ie localhost/Zend/Search/Lucene.php,localhost/Zend.../blabla.php 上的錯誤 500..
但是,某些文件在瀏覽器上運行時並未顯示此 500 服務器錯誤。 即:localhost/Zend/ProgressBar.php 顯示一個空白頁面,這很好,因為我假設代碼中沒有任何“回聲”。 這實際上是我在瀏覽器上運行 lucene.php 時所期望的......
有經驗的人可以告訴我這是怎么發生的嗎? 為什么我得到內部服務器錯誤而不是異常? 無論此內部 500 服務器錯誤如何,如何檢查使用“Lucene.php”文件的搜索應用程序是否正常運行? 謝謝。
嘗試開啟錯誤報告:
在飛行中
ini_set('display_errors', 1);
error_reporting(E_ALL);
在 php.ini 中(對於 php 和 cli 可能不同)
error_reporting = E_ALL
display_errors = 1
有關更多信息,請參閱:
我終於解決了問題:)查看錯誤痕跡后,內部服務器錯誤是因為代碼<?php require_once "C:...\Zend\Search\Lucene.php";?>
試圖訪問特定的"Lucene.php" 中的代碼包含 Zend 庫文件夾的相對路徑 = require_once('Zend\Search\Document\...');
並且服務器不知道文件的路徑。 What needed to be fixed was actually my php.ini file, on the include_path i added ;C:\php5\pear;C:\Server\www\.....\ZendFramework\library
..Now it shows empty page instead內部服務器錯誤。
+1 @Arend:報錯 function 真的很有用! 謝謝
Zend 的代碼依賴於他們的自動加載器。 你得到一個錯誤,因為你沒有初始化它,然后在 Zend_Search_Lucene 中它試圖實例化一個不存在的 class。
這應該可以解決問題:
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
self::$zendLoaded = true;
由於我無法評論答案,我重用了 Maerlyn 的代碼:
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
self::$zendLoaded = true;
不能工作,因為self
沒有定義她。
根據 ZF 文檔,如果您的路徑設置正確,那么這兩行就足夠了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.