Can't include pear package that definitely exists (and is installed)

一个人想着一个人 提交于 2019-12-23 09:38:49

问题


I installed the Mail_Mime package.

include('Mail.php');
include('Mail/mime.php');

I get the following errors:

Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php  on line 2

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 2

Warning: include(Mail/mime.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

Warning: include() [function.include]: Failed opening 'Mail/mime.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

the 2 files are definitely in the folders:

/usr/lib/php/PEAR/Mail.php
/usr/lib/php/PEAR/Mail/mime.php

pear list tells me that the packages required are installed and there are no missing dependencies


回答1:


Is it in your include path?

var_dump(get_include_path());

If it's not, try adding this before hand to add it to the include path:

at run time:

$path = get_include_path() . PATH_SEPARATOR . '/usr/lib/php/PEAR';
set_include_path($path);

Or in php.ini

include_path=".:--Whatever's here already--:/usr/lib/php/PEAR"

On a side note, if you care about it being included, why not use require_once? It'll prevent it from being included multiple times (the _once part) and causing a fatal error. It'll also prevent the execution of the rest of the code if it can't be found...




回答2:


For Plesk users using virtual hosts: don't forget to include the Directory directive in the vhost.conf in the /var/www/vhosts/yourdomain/subdomains/yoursubdomain/conf/vhost.conf when you set open_basedir to allow including the PEAR libraries

<Directory  /var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs>
        <IfModule mod_php4.c>
                php_admin_flag engine on
                php_admin_flag safe_mode off
                php_admin_value open_basedir "/var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
        </IfModule>
        <IfModule mod_php5.c>
                php_admin_flag engine on
                php_admin_flag safe_mode off
                php_admin_value open_basedir "var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
        </IfModule>
        Options -Includes -ExecCGI
</Directory>


来源:https://stackoverflow.com/questions/2882467/cant-include-pear-package-that-definitely-exists-and-is-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!