Monday, 17 September 2018

Install PHP IMAP on CentOS

If you are getting the "Fatal error: Call to undefined function imap_open()" error in PHP when using the IMAP functions then they are not installed with your installation of PHP. This post looks at how to install the PHP IMAP functions on CentOS and should also work for Red Hat Enterprise Linux (RHEL), Fedora and other derived Linux distros.
To install PHP IMAP on CentOS run the following from the command line:
sudo yum install php-imap
You'll see some output like this:
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package php-imap.i386 0:5.1.6-20.el5_2.1 set to be updated
--> Running transaction check
--> Processing Dependency: libc-client.so.1 for package: php-imap
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Package libc-client.i386 0:2004g-2.2.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 php-imap                i386       5.1.6-20.el5_2.1  updates            52 k
Installing for dependencies:
 libc-client             i386       2004g-2.2.1      base              516 k

Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 568 k
Is this ok [y/N]:
At this point type in "y" and press <enter> and then the installation will continue:
Downloading Packages:
(1/2): php-imap-5.1.6-20. 100% |=========================|  52 kB    00:26
(2/2): libc-client-2004g- 100% |=========================| 516 kB    00:08
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: libc-client                  ######################### [1/2]
  Installing: php-imap                     ######################### [2/2]

Installed: php-imap.i386 0:5.1.6-20.el5_2.1
Dependency Installed: libc-client.i386 0:2004g-2.2.1
Complete!
You'll be able to immediately access the IMAP functions from the command line interface but will need to gracefully restart Apache to access the functions in your web based scripts:
sudo /etc/init.d/httpd graceful
Now you should be able to use the PHP IMAP functions.

Related posts:

0 comments:

Post a Comment