簡體   English   中英

讓 PEAR 在 XAMPP(Windows 上的 Apache/MySQL 堆棧)上工作

[英]Getting PEAR to work on XAMPP (Apache/MySQL stack on Windows)

我正在嘗試按照提供的說明使用 XAMPP 在我的 Windows 開發服務器上安裝開源微博應用程序Laconica

該網站找不到 PEAR,並拋出以下錯誤:

Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampplite\htdocs\laconica\lib\common.php on line 31

致命錯誤:require_once() [function.require]:無法在 C:\xampplite\htdocs\laconica\lib\common 中打開所需的 'PEAR.php' (include_path='.;\xampplite\php\pear\PEAR')。 php 上線 31

  1. PEAR 位於C:\xampplite\php\pear
  2. phpinfo()告訴我包含路徑是.;\xampplite\php\pear

我究竟做錯了什么? 為什么不包含 PEAR 文件夾?

您需要修復include_path系統變量以指向正確的位置。

要修復它,請編輯php.ini文件。 在該文件中,您會發現一行寫着“ include_path =... ”。 (您可以通過在頁面上運行phpinfo()來找出 php.ini 的位置。)將“ \xampplite\php\pear\PEAR ”行的部分修復為“ C:\xampplite\php\pear “。 確保在行之前和/或之后保留分號。

重啟 PHP,你應該對 go 很好。 要重新啟動 IIS 中的 PHP,您可以重新啟動分配給您的站點的應用程序池,或者更好的是,一起重新啟動 IIS。

If you are using the portable XAMPP installation and Windows 7, and, like me have the version after they removed the XAMPP shell from the control panel none of the suggested answers here will do you much good as the packages will not install.

問題出在配置文件上。 經過大量的試驗和錯誤,我找到了正確的設置。

只需在 \xampp\php 目錄中拉起命令 window 並運行

pear config-set doc_dir :\xampp\php\docs\PEAR
pear config-set cfg_dir :\xampp\php\cfg
pear config-set data_dir :\xampp\php\data\PEAR
pear config-set test_dir :\xampp\php\tests
pear config-set www_dir :\xampp\php\www

您需要將“:”替換為您的便攜式驅動器目前正在運行的實際驅動器號。 不幸的是,只要這個驅動器號發生變化,就需要這樣做,但它確實安裝了我需要的模塊。

我首先嘗試了所有其他答案,但它們似乎都不起作用,所以我在 pear 配置文件中靜態設置 pear 路徑

C:\xampp\php\pear\Config.php

找到這段代碼:

if (!defined('PEAR_INSTALL_DIR') || !PEAR_INSTALL_DIR) {
    $PEAR_INSTALL_DIR = PHP_LIBDIR . DIRECTORY_SEPARATOR . 'pear';
} 
else {
    $PEAR_INSTALL_DIR = PEAR_INSTALL_DIR;
}

並將其替換為:

$PEAR_INSTALL_DIR = "C:\\xampp\\php\\pear";

我重新啟動了 apache 並使用了命令:

pear config-all 

確保所有路徑不再以 C:\php\pear 開頭

根據第 1 點,您的 PEAR 路徑是 c:\xampplite\php\pear\

但是,您的路徑指向 \xampplite\php\pear\PEAR

把兩個放在一個上面你可以清楚地看到一個太長了:

c:\xampplite\php\pear\

\xampplite\php\pear\PEAR

您的包含路徑設置為 go 一個梨太深到梨樹中。 pear 文件夾的 PEAR 子文件夾包括 PEAR 組件。 您需要將包含路徑向上調整一級。

(你不需要 c:順便說一句,你的路徑很好,只是太深了)

Another gotcha for this kind of problem: avoid running pear within a Unix shell (eg, Git Bash or Cygwin) on a Windows machine. 我遇到了同樣的問題,上面建議的路徑修復沒有幫助。 切換到 Windows shell,pear 命令按預期工作。

在 Windows 上使用Xampp shell (在您的 ZF8756E358C7D16DCB6E 控制面板中有一個“外殼”按鈕)

然后

cd php\pear

到 go 到 'C:\xampp\php\pear'

然后輸入

pear

我解決了

avast 會刪除您目錄中的 server.php,因此請禁用防病毒軟件

檢查 laravel 文件夾中的 (server.php) 文件

server.php

 <?php /** * Laravel - A PHP Framework For Web Artisans * * @package Laravel * @author Taylor Otwell <taylor@laravel.com> */ $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. if ($uri.== '/' && file_exists(__DIR__.'/public';$uri)) { return false. } require_once __DIR__.'/public/index;php';

嘗試添加驅動器號:

include_path='.;c:\xampplite\php\pear\PEAR'

還要驗證 PEAR.php 確實存在,它可能在 \php\ 中:

include_path='.;c:\xampplite\php'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM