How To Enable PEAR Packages In Plesk

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 20, 2008

Follow me on Twitter as @mattiasgeniar

By default, Plesk will install PEAR and a lot of packages, but block any access to it for PHP scripts. It’s fairly easy to enable this, though.

First of all, you need to edit the VirtualHost of whatever domain you’re trying to enable this for. Seeing as Plesk would just overwrite your httpd.conf with the next change you make in the controlpanel, you need to use a seperate vhost.conf file.

The file to edit can be found in the following directory:

/var/www/vhosts/<my domain>/conf/vhost.conf

It’s possible the file doesn’t exist, just go ahead and create it. If it does exist, simply edit it. If you’re trying to enable this for a subdomain only, you should edit the following file.

/var/www/vhosts/<my domain>/subdomains/<subdomain-name>/conf/vhost.conf

Once you’re editting the file vhost.conf, add the following lines.

<Directory /var/www/vhosts/<my domain>/httpdocs>
        php_admin_value include_path "/var/www/vhosts/<my domain>/httpdocs/:/usr/share/pear/"
        php_admin_value open_basedir "none"
</Directory>

You can change the Directory-name to reflect whatever directory you’re trying to modify. For a subdomain, you should include the /subdomains// location as well.

The new vhost.conf only adds the location for the PEAR packages, being /usr/share/pear/. Make sure to keep your normal httpdocs directory in there too, otherwise your other includes will fail.

Now, you should let Plesk rebuild its configuration files in order to pick up the changes made in your vhost.conf, by running the following command.

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=my-domain-name

Replace “my-domain-name” with the actual domain name for which you want to enable PEAR. The command above will rebuild the vhost config for that specific domain. If you’re interested in rebuilding it for all your domains, you can use the shorter version.

/usr/local/psa/admin/sbin/websrvmng -a -v

At the beginning I said Plesk has a lot of PEAR Packages installed by default, and that’s true. They are however, in a different directory. You can find them all here.

/usr/share/psa-pear/

You can copy any package you want or need to /usr/share/pear/, to enable them.

I suggest you update your PEAR packages before you get started, because Plesk may install quite a few of time, but they’re mostly outdated anyway. Grab your copies from the PEAR-website, and replace the files on your server.

That’s pretty much the simplest way to do it.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.