How to enable php imap extension on Amazon Linux 2

How to enable php imap extension on Amazon Linux 2
How to enable php imap extension on Amazon Linux 2

In this tutorial, we will enable or fix php imap extension on Amazon Linux AMI 2. We will need the tools to compile the module, if you don’t have them installed you can do it as follows:

sudo yum groupinstall “Development Tools”

To install the necessary dependencies we must activate the EPEL repository, if you do not have it activated do the following:


sudo amazon-linux-extras install epel


yum install epel-release


Now we install the dependencies:


sudo yum install libc-client-devel uw-imap-static openssl-devel

Now we are going to create a symbolic link for the script to find the libc-client library.


sudo ln -s /usr/lib64/libc-client.a /usr/lib



Then we will download the source code of the version of PHP that you are using from
 https://www.php.net/downloads.php


cd ~
wget https://www.php.net/distributions/php-7.x.x.tar.gz

We go to the directory that corresponds to the extension that we want to compile in this case IMAP, but this part works for any extension. We prepare the compilation environment with phpize and execute the configure script and then make


cd php-7.x.x/ext/imap
phpize
./configure –with-berberos –with-imap-ssl
make

If everything ends well without an errors, we copy the compiled module to the php modules folder


cd php-7.x.x/ext/imap/modules


sudo cp imap.so /usr/lib64/php/modules/

And we create an ini file to load it


sudo nano /etc/php.d/30-imap.in

 Add the following content to the file


extension=imap



We restart the PHP service (you may need to restart httpd depending on your php installation)

sudo systemctl restart php-fpm

OR  


sudo systemctl restart httpd

To verify if the module was correctly loaded we execute


php -m | grep imap


[ec2-user@vetechno ~]$ php -m | grep imap
imap
[ec2-user@vetechno ~]$

 

If we see something like this in the result of the console, php-imap was loaded correctly and it would be ready to go.

Conclusion:-

Congratulation you have successfully installed or enabled php imap extension on Amazon Linux 2. Please let me know in the comment box if you are facing any kind of issue, we will happy to answer.

Also Read :- How to install MySQL 5.5 on Ubuntu 20.04 LTS

Also Read :- How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu 20.04 LTS

Also Read :- How to Uninstall PHP, Apache and MySQL on Ubuntu 20.04 LTS

2 comments

Leave a Reply

Your email address will not be published.