PDA

View Full Version : Cannot access PEAR module



rongoral
February 28th, 2010, 07:29 PM
I recently installed the PEAR DB module from the CPanel. I see that it should be accessible to my scripts since it did install in the home/my_domain_alias/php directory. The problem is that 'require'-ing the module in my script is returning this error:

Fatal error: require() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/my_domain_alias/public_html/phptest/index.php on line 14

The offending line is:



require 'DB.php';


Do I need to modify the include path? Shouldn't this already be done by the PEAR installer? This is not an urgent matter for me, yet, but it certainly is frustrating. Any insight would be greatly appreciated.

Peace in Christ -
Ron

Max
March 1st, 2010, 02:54 PM
Ron,
When you install the PEAR extensions in cPanel they are installed to php directory in your home directory. So the path would be /home/USERNAME/php.

You could always double check from cPanel, if you go the PHP Pear section, on top of the page you will see:

Location of Your PHP Extension(s) and Application(s)
Path: /home/your_username/php

-Max

rongoral
March 1st, 2010, 03:55 PM
Thanks for the reply, Max.

The package has installed. While using CPanel, if I ask it to show the PHP packages installed, DB is listed. If I use an FTP program to look at the "home" directory (the one above the public_html directory), I can see that the PEAR package has been installed in the php directory. It looks as though it has installed correctly. However, my script is not finding it, hence my confusion. It is as though the PHP parser is bypassing this directory. ???

So, now I'm wondering if I need to alter the include path in some way. I did this, as an experiment early on. But, since I am not a linux admin, I'm not certain I used the correct syntax. Even so, the default include path should be sufficient. Any more ideas?

rongoral
March 1st, 2010, 05:09 PM
So, the "fix" for this is to alter my include path by adding the following php function call to the script:



ini_set('include_path',
ini_get('include_path').PATH_SEPARATOR.'/home/my_domain_alias/php');


While I am glad to be able to fix this problem, it seems that if a PEAR package is installed using the CPanel installer, the include path should be updated automatically. UNLESS, there is a single php.ini file for the server. In such a case, this IS the acceptable alternative since there are security issues with allowing individual sites on a shared server to have their own php.ini files.

I'm glad to have this answer, but wish I had come upon it a couple days ago. :rolleyes:

Peace -
Ron

Max
March 1st, 2010, 10:10 PM
Rob,
Its fine to include the path the way you have done it.

The way we generally do it is to create a php.ini file in the directory that you'll be using the PEAR extensions with the following line:

include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/YOUR_USERNAME/php"

rongoral
March 2nd, 2010, 05:30 AM
Thanks Max. Now that this is settled, I can get on with porting my PERL code. I appreciate your help.