Unable to install php extension

December 11, 2018 1.6k views
PHP Ubuntu 16.04

Hello. I’m unable to install imap php extension. The problem probably is, that I installed php version from php-archive github) and now I have php links broken?

Well, I followed every step from here: http://blog.programster.org/ubuntu16-04-compile-php-7-2-with-pthreads to install php with pthreads. It works perfectly, but when I want to install imap extension, I probably use other version of the extension?

Is I understood, installing extension should be easy as:
$ sudo apt-get install php-imap
$sudo phpenmod imap

Then extension (imap) should appear on:
$ php -m

But this doesn’t happen, so I tried to add it manually (this is probably not how you want do it, I don’t know)

  • I copied file from “/usr/lib/php/20170718/imap.so” into my: “/etc/php7/lib/php/extensions/debug-zts-20170718/imap.so”.
  • I added “extension=imap” to my php.ini file

The problem now is displaying error:

“PHP Warning: PHP Startup: Unable to load dynamic library ‘imap’ (tried: /etc/php7/lib/php/extensions/debug-zts-20170718/imap (/etc/php7/lib/php/extensions/debug-zts-20170718/imap: cannot open shared object file: No such file or directory), /etc/php7/lib/php/extensions/debug-zts-20170718/imap.so (/etc/php7/lib/php/extensions/debug-zts-20170718/imap.so: undefined symbol: file_globals)) in Unknown on line 0”

As I read, “undefined symbol: file_globals” probably means that I have wrong php API version of this extension to compile with php version. Or it has something to do with using zts?

I’m using Ubuntu 16.04 and I was literally searching for 10 hours to fix this, but I’m kinda php and Ubuntu beginner.

Any help would be highly appreciated! Thank you

1 Answer

Make sure you’re installing the correct version of imap for PHP version you’re running. In other words, is php-imap for php 7.2? Also, is the php you’re running from the CLI actually php version 7.2 (php -v) or some other php version?

Have another answer? Share your knowledge.