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)
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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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?
It seems like the issue you’re encountering is indeed related to the fact that you are using a custom-compiled version of PHP with pthreads (ZTS enabled), which requires extensions to be compiled with ZTS support as well. The IMAP extension you installed via apt-get is most likely not compiled with ZTS support, which is why it throws the error.
Here’s how you can resolve this by compiling the IMAP extension from source with ZTS support:
Ensure you have the necessary build tools and dependencies for compiling PHP extensions:
sudo apt-get update
sudo apt-get install build-essential libpcre3-dev libssl-dev libcurl4-openssl-dev libxml2-dev libicu-dev
Download the exact version of PHP that you have installed (including ZTS). For example, if you are using PHP 7.2, run:
wget https://www.php.net/distributions/php-7.2.x.tar.gz
tar -xzvf php-7.2.x.tar.gz
cd php-7.2.x/ext/imap
Now that you’re in the imap extension directory, run phpize to prepare the environment for compiling:
phpize
This will generate the necessary configuration files to compile the extension with your custom PHP build.
Next, configure and compile the IMAP extension:
./configure --with-php-config=/path/to/php-config --with-kerberos --with-imap-ssl
make
sudo make install
/path/to/php-config with the path to the php-config file for your custom PHP installation. You can locate it using which php-config.make install step will copy the compiled imap.so file to the correct extensions directory.After the IMAP extension is compiled and installed, enable it by adding the following line to your php.ini file:
extension=imap.so
Restart your web server (Apache, Nginx, or PHP-FPM):
sudo systemctl restart apache2 # for Apache
sudo systemctl restart php7.x-fpm # for PHP-FPM
Finally, verify that the IMAP extension is loaded by running:
php -m | grep imap
You should see imap listed as one of the installed modules.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.