简体   繁体   English

让 PEAR 在 XAMPP(Windows 上的 Apache/MySQL 堆栈)上工作

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

I'm trying to install Laconica , an open-source Microblogging application on my Windows development server using XAMPP as per the instructions provided .我正在尝试按照提供的说明使用 XAMPP 在我的 Windows 开发服务器上安装开源微博应用程序Laconica

The website cannot find PEAR, and throws the below errors:该网站找不到 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 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

Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path='.;\xampplite\php\pear\PEAR') 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 is located in C:\xampplite\php\pear PEAR 位于C:\xampplite\php\pear
  2. phpinfo() shows me that the include path is .;\xampplite\php\pear phpinfo()告诉我包含路径是.;\xampplite\php\pear

What am I doing wrong?我究竟做错了什么? Why isn't the PEAR folder being included?为什么不包含 PEAR 文件夹?

You need to fix your include_path system variable to point to the correct location.您需要修复include_path系统变量以指向正确的位置。

To fix it edit the php.ini file.要修复它,请编辑php.ini文件。 In that file you will find a line that says, " include_path =... ".在该文件中,您会发现一行写着“ include_path =... ”。 (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, " \xampplite\php\pear\PEAR " to read " C:\xampplite\php\pear ". (您可以通过在页面上运行phpinfo()来找出 php.ini 的位置。)将“ \xampplite\php\pear\PEAR ”行的部分修复为“ C:\xampplite\php\pear “。 Make sure to leave the semi-colons before and/or after the line in place.确保在行之前和/或之后保留分号。

Restart PHP and you should be good to go.重启 PHP,你应该对 go 很好。 To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.要重新启动 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. 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.

The problem is with the config file.问题出在配置文件上。 I found the correct settings after a lot of trial and error.经过大量的试验和错误,我找到了正确的设置。

Simply pull up a command window in the \xampp\php directory and run只需在 \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

you will want to replace the ':' with the actual drive letter that your portable drive is running on at the moment.您需要将“:”替换为您的便携式驱动器目前正在运行的实际驱动器号。 Unfortunately, this needs to be done any time this drive letter changes, but it did get the module I needed installed.不幸的是,只要这个驱动器号发生变化,就需要这样做,但它确实安装了我需要的模块。

I tried all of the other answers first but none of them seemed to work so I set the pear path statically in the pear config file我首先尝试了所有其他答案,但它们似乎都不起作用,所以我在 pear 配置文件中静态设置 pear 路径

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

find this code:找到这段代码:

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

and just replace it with this:并将其替换为:

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

I restarted apache and used the command:我重新启动了 apache 并使用了命令:

pear config-all 

make sure the all of the paths no longer start with C:\php\pear确保所有路径不再以 C:\php\pear 开头

AS per point 1, your PEAR path is c:\xampplite\php\pear\根据第 1 点,您的 PEAR 路径是 c:\xampplite\php\pear\

However, your path is pointing to \xampplite\php\pear\PEAR但是,您的路径指向 \xampplite\php\pear\PEAR

Putting the two one above the other you can clearly see one is too long:把两个放在一个上面你可以清楚地看到一个太长了:

c:\xampplite\php\pear\ c:\xampplite\php\pear\

\xampplite\php\pear\PEAR \xampplite\php\pear\PEAR

Your include path is set to go one PEAR too deep into the pear tree.您的包含路径设置为 go 一个梨太深到梨树中。 The PEAR subfolder of the pear folder includes the PEAR component. pear 文件夹的 PEAR 子文件夹包括 PEAR 组件。 You need to adjust your include path up one level.您需要将包含路径向上调整一级。

(you don't need the c: by the way, your path is fine as is, just too deep) (你不需要 c:顺便说一句,你的路径很好,只是太深了)

Another gotcha for this kind of problem: avoid running pear within a Unix shell (eg, Git Bash or Cygwin) on a Windows machine. Another gotcha for this kind of problem: avoid running pear within a Unix shell (eg, Git Bash or Cygwin) on a Windows machine. I had the same problem and the path fix suggested above didn't help.我遇到了同样的问题,上面建议的路径修复没有帮助。 Switched over to a Windows shell, and the pear command works as expected.切换到 Windows shell,pear 命令按预期工作。

On Windows use the Xampp shell (there is a 'Shell' button in your XAMPP control panel)在 Windows 上使用Xampp shell (在您的 ZF8756E358C7D16DCB6E 控制面板中有一个“外壳”按钮)

then然后

cd php\pear

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

then type然后输入

pear

I fixed我解决了

avast deletes your server.php in your directory so disable the antivirus avast 会删除您目录中的 server.php,因此请禁用防病毒软件

check the (server.php) file on your laravel folder检查 laravel 文件夹中的 (server.php) 文件

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';

Try adding the drive letter:尝试添加驱动器号:

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

also verify that PEAR.php is actually there, it might be in \php\ instead:还要验证 PEAR.php 确实存在,它可能在 \php\ 中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM