Home » Development » Problems when compiling PHP Extensions with Pecl

Problems when compiling PHP Extensions with Pecl

This is just a very short post to offer some advice to any developers who are adding PHP extensions to their wordpress environment using the pecl tool. This is a tool which compiles extensions and links them to the PHP binary so they run correctly. When the install process takes place, a few tools are used to create the build files etc and run the compile process.

If you have more than one version of php installed it’s easy to get into the situation where you run the command

and after the process completes you find that the module won’t load. Normally there will be a message about the extension you have just added being missing. This has happened to me on a couple of occasions on an Ubuntu machine and the last time it took me about 30 minutes digging around before I found the problem, so I thought I’d add this post and hopefully save someone else some time.

In a nutshell, the problem I had was that the extension was being compiled for the wrong version of PHP. That part was actually quite easy to find out; running

showed me that the version I was using was PHP 7.1 so I assumed one of the other versions I had installed (7.0 and 7.2) had been used to compile the extension. I guessed that the problem was the phpize program and sure enough running

showed me that the version which was being used was for php 7.2.

With that corrected I expected everything to work and re-ran the pecl install command, only to find the same problem. It was only after 30 minutes messing about and searching google that I found there is also a php-config program which also needs to be the correct version. After I’d also run

I found the pecl install program installed the extension into the correct path and everything worked properly.

So the thing to remember is that there are actually 3 different commands to run to change both the PHP version and the build system.


Leave a Reply

error: Content is protected !!
%d bloggers like this: