Changing the php extension directory in order to use PEAR/PECL on shared hosting

I’m having a problem that I’ve seen mentioned but not solved in the forums. I’m hoping that it is something somebody with more active experience with PHP, PEAR, and PECL will have a quick answer to.

The problem is that when I install PECL/APCu, I end up with a permissions error for the php extensions library:

Build process completed successfully
Installing '/usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/'
ERROR: failed to write /usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/ (copy(/usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/ failed to open stream: Permission denied)

I installed PEAR following the instructions in the wiki. I’ve modified my bash_profile, .bashrc, and built a phprc as described in that wiki and associated pages. And I fixed the problem with PECL throwing errors discussed here (this is largely for my own benefit, since I’ve had to find this a few times).

I did notice that the directory showing up in the error was listed as my php extensions directory when I checked my pear config-show and also that on many form pages, people seemed to have set that to something under their home directory. So I changed the extension directory to one in my home directory using pear config-set ext_dir /home/$USR/pear/ext (I got this command from the Pear Dreamhost Wiki entry mentioned above and extended it to this directory).

Despite all this, I’m still getting the error. Changing the ext_dir setting seems to have no effect on where PECL is trying to set up the extension.

Any advice? Anybody know of a solution?

Perhaps too late to help, but I had the same problem.

According to
The user specified ext_dir is not respected.
Reading through this, I couldn’t find evidence of it actually being fixed.

The way I solved it was by noticing that after the build fails, it doesn’t clean up the pear tmp directory.

You couldn’t have gotten this far without creating this in your user directory.
In my case, I made it in /home/user/pear/tmp/

  1. Navigate to your pear tmp directory, and edit the Makefile

  2. Modify EXTENSION_DIR to your preferred location.
    Save and exit.

  3. Now ‘make’ - and all going well, it should finally install correctly.

It is my understanding that you’ll need to point php/pear to that extension in your php.ini/phprc file.
(If it hasn’t already)

Good luck!


I found my [] located in /home/user/pear/tmp/modules
I found this location was outputted by the make process.

After the make operation completed.

  1. Copied the newly compiled [] file to /home/user/pear/extensions directory manually.

  2. Copied all extensions from usr/local/php56/lib/php/extensions to /home/user/pear/extensions

  3. Updated /home/user/.php/5.6/phprc with two new lines:
    extension_dir = /home/user/pear/extensions
    extension = [extension].so