这是报错信息 This example script is written to run under the command line ('cli') version of the PHP interpreter, but you're using the 'apache2handler' version
下面是我运行的php 文件 内容 
if (php_sapi_name() != "cli")  {  //应该是这句话 是不是要配置某个选项 支持 cli啊  
    print "This example script is written to run under the command line ('cli') version of\n";
    print "the PHP interpreter, but you're using the '".php_sapi_name()."' version\n";
    exit(1);
}include "xapian.php";if ($argc != 2) {
    print "Usage: {$argv[0]} PATH_TO_DATABASE\n";
    exit(1);
}try {
    // Open the database for update, creating a new database if necessary.
    $database = new XapianWritableDatabase($argv[1], Xapian::DB_CREATE_OR_OPEN);    $indexer = new XapianTermGenerator();
    $stemmer = new XapianStem("english");
    $indexer->set_stemmer($stemmer);    $para = '';
    $lines = file("php://stdin");
    foreach ($lines as $line) {
$line = rtrim($line);
if ($line == "" && $para != "") {
    // We've reached the end of a paragraph, so index it.
    $doc = new XapianDocument();
    $doc->set_data($para);     $indexer->set_document($doc);
    $indexer->index_text($para);     // Add the document to the database.
    $database->add_document($doc);     $para = "";
} else {
    if ($para != "") {
$para .= " ";
    }
    $para .= $line;
}
    }    // Set the database handle to Null to ensure that it gets closed
    // down cleanly or uncommitted changes may be lost.
    $database = Null;
} catch (Exception $e) {
    print $e->getMessage() . "\n";
    exit(1);
}
?>

解决方案 »

  1.   

    command-line interface 命令行界面
    用命令行工具运行它 linux命令行,或win的cmd都可以
      

  2.   

    類似於shell吧..就是命令行工具了,環境變量什麼的當然就不一樣了。如果你的腳本是web的那就不要在cli下調試,否則多數可能都會出錯。其他的不是很瞭解,cli基本沒有這麼在下面跑過東西
      

  3.   

    意思是说,你的这段代码是设计运行在CLI模式下的,但是你现在用的是apache web服务器, 所以这段代码不能运行.
    CLI 是命令行模式,例如在winXP 的命令行窗口cmd 里边,php my_script.php 使用php.exe 直接运行php代码,相当于控制台应用。
    不是web服务器上运行的。
    真需要的话,改成 web服务器上运行的版本就可以。$argv[0] 是从命令行获取的参数,改成用变量设置或$_GET或$_POST 获得