繁体   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