Adding IMAP support to your PHP build on Red Hat Enterprise Linux can involve navigating some pretty obscure error messages, not to mention some pretty old-school builds
You’re building PHP 5.4 on your Red Hat Enterprise Linux server and find your configure command is blowing up:-
checking for U8T_DECOMPOSE... configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
You’re not sure why; and with that error message I can’t blame you!
Scrolling back a little in the output might give you a clue though:-
checking for IMAP support... yes checking for IMAP Kerberos support... no checking for IMAP SSL support... no checking for utf8_mime2text signature... new checking for U8T_DECOMPOSE... configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
The previous messages suggest a link with IMAP and sure enough, there’s a –with-imap lurking in your configure command.
What the message is actually telling you is that the IMAP client library that PHP IMAP uses is either not present on your system or is just possibly hopelessly out of date.
The PHP IMAP documentation will point you at the c-client library hosted on http://www.washington.edu/imap/ as a requirement. Searching your system for a libc-client.a library will tell you whether you haven’t got it or if you just need an upgrade.
The RPM route
Fortunately Red Hat do provide RPMs containing the required files and if you don’t already have a version installed adding these packages will probably be your quickest solution.
If you’re searching for something with IMAP in its name by way of a clue though you’ll draw a blank. On my RHEL 5.6 system the required RPMS are:-
libc-client-2004g-2.2.1.i386.rpm libc-client-devel-2004g-2.2.1.i386
You’ll need both the libc-client and the libc-client-devel package installed as your PHP build will need to link to it. If you’re running a different RHEL version a yum list | grep libc-client should track down the versions you need.
These libraries are built with Kerberos and SSL support so you’ll also need to add –with-kerberos and –with-imap-ssl to your PHP configure command, though if you don’t it will tell you to to do it:-
configure: error: This c-client library is built with Kerberos support. Add --with-kerberos to your configure line. Check config.log for details. … configure: error: This c-client library is built with SSL support. Add --with-imap-ssl to your configure line. Check config.log for details.
Once you’re past these both configure and make should be happy.
The build from source route
If you already have another version of libc-client installed and you don’t want to disturb it, or you don’t have convenient access a pre-built version, you can download the IMAP source package from http://www.washington.edu/imap/ and build it yourself. For anyone used to the slick and easy configure -> make -> make install process though this one is a little old-school.
First of all you’ll need to navigate the FTP directory to find the latest version. Fortunately there’s a link to the latest imap.tar.gz which is the one go to for. Currently the underlying file is imap-2007f.tar.gz.
Once extracted you’ll notice the lack of the usual configure script. To build this library there’s just a plain Makefile and if you run make it’ll instantly tell you off:-
Not processed yet. In a first-time build, you must specify the system type so that the sources are properly processed. make: *** [c-client] Error 1
You need to look in the Makefile and identify the “code” for your platform in the rather lengthy list at the top. For Red Hat Enterprise Linux lr5 is the magic code so you’ll need to run make lr5 to build it which, at least on my system, spews a few pages of errors:-
# make lr5 … … osdep.c:138: error: expected ‘)’ before ‘*’ token osdep.c: In function ‘checkpw’: osdep.c:155: error: ‘pam_handle_t’ undeclared (first use in this function) osdep.c:155: error: ‘hdl’ undeclared (first use in this function) osdep.c:156: error: storage size of ‘conv’ isn’t known osdep.c:164: error: ‘PAM_SUCCESS’ undeclared (first use in this function) osdep.c:165: error: ‘PAM_RHOST’ undeclared (first use in this function) osdep.c:168: error: ‘PAM_ESTABLISH_CRED’ undeclared (first use in this function) osdep.c:184: error: ‘checkpw_cleanup’ undeclared (first use in this function) make[3]: *** [osdep.o] Error 1 make[3]: Leaving directory `/home/builds/imap-2007f/c-client' make[2]: *** [lnp] Error 2 make[2]: Leaving directory `/home/builds/imap-2007f/c-client' make[1]: *** [OSTYPE] Error 2 make[1]: Leaving directory `/home/builds/imap-2007f' make: *** [lr5] Error 2
Without the helpful configure script to check your dependencies you’re down to looking at the build errors to identify what you’re missing. In most cases this sort of error will come down to a missing header or library and they’re usually one of the first errors to appear. Scrolling up towards the top reveals the source of this problem:-
osdep.c:89:31: error: security/pam_appl.h: No such file or directory
The PAM Development package is missing, which on my RHEL 5.6 system lurks in pam-devel-0.99.6.2-6.el5_5.2.i386.rpm. Adding that to my system gets me a clean, local build which conveniently sticks the required headers and library files in a single directory which I can point my PHP configure command at:-
# ./configure --with-imap=/home/builds/imap-2007f … configure: error: This c-client library is built with SSL support. Add --with-imap-ssl to your configure line. Check config.log for details.
If the IMAP c-client build spotted OpenSSL on your system it will have built with SSL support included so you’ll need to tell the PHP configure script to use it:-
# ./configure --with-imap=/home/builds/imap-2007f --with-imap-ssl
If you’re building PHP 5.4.22 or later that should just about do it for you, but with older PHP versions you might get the following error:-
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
You might think you’re pointing your configure command at the wrong directory (and if you’ve made the mistake of including the c-client sub-folder in the path that could well be it) but the problem is more likely to be that the IMAP c-client build generates a file called c-client.a whereas the build chain is looking for libc-client.a. Newer PHP builds automatically create a link for you but if you’re using an older build you’ll need to do it yourself.
# cd /home/builds/imap-2007f/c-client # ln -s c-client.a libc-client.a
This time your configure command should find what it needs.