0

I've tried every way to install imap php extension but I couldn't do it. I am using amazon web service EC2 instance and it has CentOS. while yum search *-imap.* I found a package from cyrus-imap.* but it's not working. I've installed it but it seems to be not the package I want. I have tried many things but there are no package with php-imap on cent os.

My application badly needs php-imap extension. My php config

# php -v 
PHP 7.2.31 (cli) (built: Jul  2 2020 23:17:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Can anyone help? Thanks in advance.

MD Nasirul Islam
  • 145
  • 1
  • 12
  • Give the article linked above a go. It has pretty clear instructions. If it doesn't work hit the "reopen" link and let us know why the other answer didn't work :) – Tim Sep 03 '20 at 07:40
  • Thank you for suggesting the answer but it isn't helping, well i've tried that but its not working. the problem is on my ec2 linux 2 ami can't even install the **epel release** so my problem is getting worse. – MD Nasirul Islam Sep 03 '20 at 09:23
  • But thanks anyway i got a solution here it is found it on [This link](https://omicronthetablog.wordpress.com/2019/11/13/instalar-php-imap-en-amazon-linux-2/) Basically i had to install the epel-release after i installed some extra things 1 - ```sudo yum groupinstall "Development Tools"``` 2 - ```sudo amazon-linux-extras install epel``` 3 - ```yum install epel-release``` 4 - ```sudo yum install libc-client-devel uw-imap-static openssl-devel ``` – MD Nasirul Islam Sep 03 '20 at 09:28
  • The rest of the instructions are on the link. the main problem is solved now it can be easily solved – MD Nasirul Islam Sep 03 '20 at 09:35
  • Beware: EPEL is not guaranteed to be compatible with Amazon Linux or Amazon Linux 2. Packages you install from EPEL onto Amazon Linux (2) may not work correctly, or may not be installable, or may stop working in the future. It is irresponsible for Amazon to keep offering it the way they do. If you need packages from EPEL, you should run CentOS or RHEL instead of Amazon Linux. – Michael Hampton Sep 03 '20 at 14:27
  • Good to hear you solved it. To help others in future please answer your own questions, give people step by step instructions how to solve the problem. I tend to use Ubuntu as it's got the best documentation and support, and most packages built for it. – Tim Sep 03 '20 at 18:21

1 Answers1

3

The main problem with imap is that this package is not available as php-imap on amazon linux 2 so we need to choose some alternative way. The main problem is to configure the essential files that are needed to build the imap setup files. So the total procedure is two steps.

  • One is to setup the development tools.
  • Two is to build imap from the setup files.

Follow my instructions as given below

  • sudo yum groupinstall "Development Tools"
  • install epel realese sudo amazon-linux-extras install epel and then yum install epel-release
  • install some dependencies sudo yum install libc-client-devel uw-imap-static openssl-devel
  • Create the symlink sudo ln -s /usr/lib64/libc-client.a /usr/lib
  • Now download the full php files from the official php website. We will be needing the core files to build the imap extensions. Go to your root folder by cd~ then wget https://www.php.net/distributions/php-7.x.x.tar.gz
  • Untar the tar.gz: tar -xf php-7.x.x.tar.gz
  • Now go to the directory
cd php-7.x.x/ext/imap
phpize
./configure --with-kerberos --with-imap-ssl
make
  • Go to the modules folder and type cd php-7.x.x/ext/imap/modules
  • sudo cp imap.so /usr/lib64/php/modules/
  • Then open with nano sudo nano /etc/php.d/30-imap.ini and write extension=imap
  • Restart httpd or php fmp sudo systemctl restart php-fpm and sudo systemctl restart httpd
  • Done. You can view it by typping php -m | grep imap it will show imap in red font. Done TIA
Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
MD Nasirul Islam
  • 145
  • 1
  • 12