Php pear

software development

#1

Does Dreamhost support PHP PEAR?


#2

yes we do!

josh!


#3

The official response I received from Dreamhost is:

“Not yet, but I suspect we will shortly. We’re currently running PHP v4.2.3, and have been waiting for PHP v4.3.2 (which includes PEAR) to come out before upgrading. It appears that it has just been released, so I’d expect us to support it once we put it through some testing and find some time to install it on our servers. I don’t have a timeframe right now, but we will be sure to make an announcement once it is ready.”


#4

Dreamhost has a few PEAR modules installed, but Jeff from support says Dreamhost doesn’t add other PEAR modules on request.

They have the excellent PEAR::DB module and not the PEAR::Auth module. I’m looking to use the Auth module.

Does anyone know how you could set up a PEAR distribution in your home directory?

Is it a simple matter of adding:

php_value include_path “.:/home/username/php”

to an htaccess file and dumping PEAR and the relevant modules in ~/php ? What effect would this have on the existing PHP include_path?

-ed


#5

Looks like installing PEAR in your home directory works well, and is painless!

  1. Create a directory to install PEAR: e.g. [color=#0000CC]~/php[/color].

  2. Run “lynx -source http://go-pear.org | php” in this directory.

  3. During the installation, change the directories to match your configuration. PEAR will create directories as appropriate. Don’t forget to change PEAR’s bin directory to something you can write to, e.g.: [color=#0000CC]~/bin[/color].

  4. PEAR should then download all the sources and configure itself using the directories provided above.

  5. Run “~/bin/pear config-show” to see the configuration of your new PEAR installation. Ensure these directories are writable and readable by your user and apache. Use “~/bin/pear config-set setting value” to modify these settings to your ~/php PEAR installation.

  6. Add the “[color=#CC0000]~/bin/pear[/color]” binary to your path. If your shell is BASH, type “export ~/bin:$PATH”. Don’t forget to add this to your .bash_profile, using “echo PATH=~/bin:$PATH >> ~/.bash_profile”!

  7. Simply add “[color=#CC0000]php_value include_path “.:/home/username/php”[/color]” to an htaccess file telling PHP to use your new PEAR installation.

  8. Enjoy the fruits of your labour.

Don’t miss out on the invaluable online documentation: http://pear.php.net.

  • ed

#6

Just following up on Eddo88’s terrific post on installing PEAR: If you are a bit new to *nix, PHP, etc. (like me), you might want some stuff spelled out even more explicitly. You probably don’t need to read this if you have a thorough understanding of Linux/Unix already.

I just spent a considerable amount of time working on this stuff, and got it working, and I had no idea what I was doing when I started out.

During installation, you must (AFAIK) change option #1, the install-prefix, to the equivalent of ‘/home/yourusername/php/’ (with ‘php’ being the name of the directory you created to download/install PEAR into).

I could not get part of step 6 to work: “export ~/bin:$PATH” kept returning “not a valid identifier”. I’m sure it’s obvious to more experienced users why, but I couldn’t figure it out, no matter how many variations I tried. However, I think this problem was rendered moot by performing the rest of Eddo’s step 6. You have to list the path to PEAR in your .bash_profile, so PHP knows where to find it. Your .bash_profile is in your home directory, even if you can’t see it. (Try ‘ls -a’ to see it.) Edit this file using any old text editor. (You can type ‘pico .bash_profile’ to edit it.)

Once you’ve got it open, add in a line like this:

PATH=$PATH:home/yourusername/php/bin

Save the file using ctl-O.

As Eddo says in step 7, you next have to modify your .htaccess file so php knows where to look for your PEAR include files. Go into the base directory of your website and do ‘pico .htaccess’. Add the line suggested by Eddo, making sure the directory you add is the like ‘.:home/yourusername/php’ [again, where ‘php’ is the directory you created]. If you follow the rest of the steps below and it doesn’t work, edit this line so that it has that weird directory name you sometimes see (instead of ‘home/yourusername’ it goes ‘home/.strangewordsadded/yourusername’). I did this and it worked.

Finally, depending on what your scripts are doing (I think), it seems like you may have better luck if you name the file containing your scripts with a .pcgi extension instead of a .php extension. If you don’t, you may get the ‘open_dir restriction in effect’ message. (I did.) For an explanation of why changing it to .pcgi works, see:

https://panel.dreamhost.com/kbase/index.cgi?area=2526

The PEAR packages I’m using are the XML_RSS and XML_Tree packages. For these and other packages, you may need to edit their scripts so that the ‘require’ functions go to the correct relative path.

In any case, good luck – I hope this (overly?) explicit post saves you some frustration. If I made any errors in my comments, which is quite possible, please reply to this post to clarify.


#7

I am a complete newbie to this. How do these instructions compare/differ from those found on the official PEAR site:
http://pear.php.net/manual/en/installation.shared.php

I need to know which set of instructions to follow.

Thanks.


#8

One more thing to add: You can follow all of the steps above, and still have problems with your include_path setting for the PEAR modules – IF you are running PHP as CGI rather than as an Apache module. (See the Domains:Web control panel to check your setting.)

If you are running PHP as CGI, adding the include_path to your .htaccess file will have NO EFFECT. Thanks to Nathan at DH support for pointing this out to me.

If you wish to use “include” and “require” functions to load your PEAR modules into your scripts and you are running PHP as CGI, you MUST either make the path to the module explicit in your script, like:

require (’/home/yourusername/php/bin/php/lib/yourmodule.php’)

OR

you can use PHP’s ini_set function at the beginning of whatever script calls the PEAR module, like:

ini_set(“include_path”,".:/usr/local/lib/php:/home/yourusername/php/lib/php");
require (‘yourmodule.php’)

I am not an expert, but I think I’d choose the second option, because if you use the first option, the ‘require’ functions within the PEAR modules themselves may not know where to find their dependencies.

This drove me crazy for the better part of a morning, so I hope this tip helps you out.


#9

Hello,
I am having real problems using pear on shared host.
I have installed a local version of pear at http://mydomain/php/PEAR/ and tried to include it into my page using

<?php ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . "/home/server/mydomain/php/PEAR/" ); set_include_path( get_include_path() . PATH_SEPARATOR . '/home/server/mydomain/php/PEAR/' ); // include PEAR mail classes include('Mail.php'); include('Mail/Mime.php'); ?>

I receive the following errors

Warning: require(Mail/Mime.php) [function.require]: failed to open stream: No such file or directory in /mnt/local/home/server/mydomain/send_newsletter.php on line 16

Fatal error: require() [function.require]: Failed opening required ‘Mail/Mime.php’ (include_path=’.:/usr/local/php5/lib/php:/usr/local/lib/php:/home/server/mydomain/php/PEAR/:/home/server/mydomain/php/PEAR/’) in /mnt/local/home/server/mydomain/send_newsletter.php on line 16

Can someone please help, I have search and followed many different tutorials but still cant get it to work.
Thanks


#10

Not to resurrect this thread, but I was directed here by Dreamhost support and in case anyone else is sent this way, you should know that the PEAR team lost the go-pear.org domain quite some time ago and it looks like it’s not coming back. PEAR bug report: http://pear.php.net/bugs/bug.php?id=12250.
Annoyed: You try the install command and it fails.
Worst Case: You try the install command and get something nasty from the domain squatter.

I followed some directions from here: http://wiki.dreamhost.com/PEAR in order to fill in the blanks. Hope it helps someone else.