We frequently get users on #pear (@efnet) who happen to run Plesk and need help setting up PEAR. Now running any config interface is a blog entry by itself and when I say Plesk, I should also mention confixx and cpanel. And while I have a strong dislike for all them, let me focus on Plesk for now.
This is not a copy'n'paste howto, so make sure you double-check all steps involved. With little knowledge, you should be able to to apply all instructions to any other control panel, all you need is SSH access to the server.
I installed PEAR, but it's not working
The number one reason here is that even though the
include_path is setup correctly, you also run with
open_basedir. For pseudo security reasons, Plesk typically restricts
open_basedir to your "document root", for example:
httpdocs is the document root.)
To verify the above, create a file called
httpdocs, with the following content:
<?php phpinfo(); ?>
include_path, it should contain something like
/usr/share/php/pear and the
open_basedir, which should contain this setting as well -- but doesn't.
To understand the issue entirely, let's look at how plesk builds virtual hosts.
- Each domain name has its own virtualhost include file, called
http.include is located in:
- The settings (e.g.
open_basedir) are set using
_value which makes overriding through
- The Annoying: Hack
http.include and lose changes each time Plesk rebuilds your hosts (with each update). :-)
- The high road: Find and edit Plesk's default template to add your PEAR installation to the
open_basedir directive, or to turn off
open_basedir completely. In this, case, what you're looking for is called "domain template" in Plesk, but because I'm not a Plesk user, I don't know much about it -- feel free to correct me.
- The intermediate fix: Run your own local PEAR installation for each domain name.
Running your own PEAR installation
Running your own PEAR installation per domain name is a pretty solution, even if you managed to rid yourself of
open_basedir, there are a couple strong points.
- Dependencies, local and trackable -- vs. global (one installation per server).
- This allows you to use different versions of packages when required by the software you use/run.
- You can't really have enough PEAR. :-)
Note: you may need to adjust the paths, my examples are from a Plesk install on SuSE.
This is assuming that you already installed one copy of PEAR through your system's package manager -- for example, aptitude on Debian and Ubuntu, yast on SuSE, rpm on RedHat(e) and CentOS or ports/pkg on all BSDs.
Go into your domains document root and create a
pear config-create /srv/www/vhosts/domain.com/httpdocs/my_pear .pearrc
This should create a
.pearrc file in the current directory, which holds the local installations' settings.
How do we use it?
If your website user has ssh, you move the
.pearrc to the users home directory, which is the directory you end up in when you login via ssh.
mv /srv/www/vhosts/domain.com/httpdocs/.pearrc /srv/www/vhosts/domain.com/
To test if the
.pearrc file is being read, issue the following:
The screen should show paths which contain
If that is not the case, try the following:
pear -c /srv/www/vhosts/domain.com/.pearrc config-show
If it's working, continue to install the packages you need. Since this is a new installation, the first should be PEAR itself:
pear install PEAR
pear -c /srv/www/vhosts/domain.com/.pearrc install PEAR
If you followed this guide, I hope it enabled you to have a different -- yet maintainable -- PEAR setup per directory. All you need is to use a different PEAR config file using the
Further information is available on the PEAR manual.