Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PEAR - Failed include DB.php

Status
Not open for further replies.

lunaward

Technical User
Sep 23, 2004
6
GB
Hi,

I've got PEAR 1.3.5 installed on a local FreeBSD (4.9 RELEASE) server.
PHP 4.3.6 has an include path of include_path.:/usr/local/share/pear.:/usr/local/share/pear
and the PEAR modules are indeed installed into
/usr/local/share/pear
I installed DB.php, Mail.php and some others.

Calling DB.php from a PHP page with:
require_once 'DB.php';
I get the error:
Fatal error: main(): Failed opening required 'DB.php' (include_path='.:/usr/local/share/pear') in /home/mysite/htdocs/save_mail_db.php on line 389

I read to check for permissions on the .lock file in the /pear/ directory, but they are:
-rw-rw-rw- 1 root wheel 0 Mar 14 11:13 .lock
and all the subfolders are readable by world.

Is there something I'm missing here that would fix my install?

I've never tried to use PEAR on the local server before (it's working fine for me on a hosted server at the ISP, but I want to test stuff out).

Thanks
 
is the db.php file in the directory /usr/local/share/pear?
I would suspect it is not (perhaps in a sub of this dir).

 
Hi,
yes, DB.php is in /usr/local/share/pear with the following persmission (installed through pear and not touched afterwards!)
-rw-r--r-- 1 root wheel 38937 Mar 14 11:12 DB.php

There is also a DB subdirectory
drwxr-xr-x 2 root wheel 512 Mar 14 11:12 DB
with the various .php files contained in it.

I wondered if it was permissions, but it's world readable, so should be ok?
And I'm definitely calling 'DB.php' - ie correct case.

I'm not very familiar with PEAR, but all my reading suggests this set up is standard and ok. PEAR was pre-installed with PHP 4.3.6 but I upgraded pear with the command-line pear utility as I didn't have any PEAR classes previously installed.

Thanks,
 
just to double check - try hardcoding the location of db.php into the require statement.

Code:
require("//absolute/path/to/db.php");
 
Hi there,

Thanks, tried
require("/usr/local/share/pear/DB.php");
and
require("//usr/local/share/pear/DB.php");
No joy :-(

requireFatal error: main(): Failed opening required '/usr/local/share/pear/DB.php' (include_path='.:/usr/local/share/pear')

Very wierd.
BTW it's the same with other PEAR files too - tried Mail.php with same error.
 
i'm not familiar with freebsd. is the notation you used above the absolute reference?

could you try checking whether the file exists in php first?

Code:
error_reporting(E_ALL);
$filename = "usr/local/share/pear/DB.php";
if (is_file($filename))
{ 
  echo "File exists";
  //now try to open it to test
  $fh=fopen($filename, "rb");
  fpassthru($fh);
}
else
{
  echo "File cannot be found";
}
 
Hi there,

tried that thanks - with path as "/usr/local/share/pear/DB.php"
I get
[tt]Warning: is_file(): Stat failed for /usr/local/share/pear/DB.php (errno=13 - Permission denied) in /usr/home/alun/httpd/htdocs/testoxfordarts/htdocs/pear-test2.php on line 4
File cannot be found[/tt]
and if the path is just plain wrong - ie "usr/local/share/pear/DB.php" I just get plain old
[tt]File cannot be found[/tt]

So - permissions? But presumably permissions are differently required for is_file, and just for require since the path is in my php.ini include path already?

I tried chmod-ing the file and DB subdirectory and chowning them to (the user running the Apache process), but no joy.

I tried copying the DB.php and DB directories over to my document root and chmod-ing them to the folder owner. Success, except for the calls to PEAR.php which still exists in the correct PEAR location. So that's a workaround, if I copy them all, but it's not ideal.

Just tried upgrading to PHP 4.3.10 to see if that helps - and now in addition to the same problem as above all my PHP scripts are failing (including known live working ones on PHP 4.3.10 elsewhere) - oh dear, time to take a break. I'll let you know how I get on after the break!
 
this is a plain old permissions issue. but i'd guess it is compounded with safe mode.

try turning off safe mode and seeing whether your problems go away. you might even be able to return the db.php directory whence it came (ensure read permissions are set for the apache user).

if that fails, i'd move the whole pear directory (and subs) to somewhere where you can guarantee access from the web account. remember to change the directory parameters in the pear config file.

hth
Justin
 
Hi,
a quick update - I removed the FreeBSD installations of Apache and PHP (previously installed through the ports collection), and downloaded and manually installed Apache 1.3.33 and PHP 4.3.10, edited the php.ini file to include /usr/local/share/pear and lo and behold, PEAR now works fine. Woopee! The ports collection has almost been the simplest way to install software in the past, but something odd has presumably crept in along the way.

No more permissions issues etc - it's all sorted!
 
And I forgot to say - thanks for sticking with me Justin!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top