Compiling PHP 7 with IMAP

noaptus

Verified User
Joined
May 17, 2018
Messages
8
I have been trying to install IMAP php extension to php7 but Im unable to find how to guide.

What I have done is try to use imap_php.sh and what I get is this error


configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

The post I have found is really old deom 2008 up to 2011.

Nothing works.

Could some one assist me on this.

Best regads

Noaptus.
 
still errors

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

*** There was an error while trying to configure php. Check the configure file



This is the error I get trying to use what you pointed me to.

Code:
[root@hq scripts]# sh ./setup-imap.sh 
Downloading imap-2007f.tar.Z...
--2019-01-16 23:12:51--  ftp://ftp.cac.washington.edu/imap/old/imap-2007f.tar.Z
           => 'imap-2007f.tar.Z'
Resolving ftp.cac.washington.edu (ftp.cac.washington.edu)... failed: Name or service not known.
wget: unable to resolve host address 'ftp.cac.washington.edu'

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
./setup-imap.sh: line 31: cd: imap-2007f: No such file or directory
Installing imap-2007f...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't open src/osdep/unix/Makefile: No such file or directory.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't open src/osdep/unix/Makefile: No such file or directory.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't open src/osdep/unix/Makefile: No such file or directory.
make: *** No rule to make target `slx'.  Stop.
Copying files to /usr/local/php-imap
cp: cannot stat 'c-client/*.h': No such file or directory
cp: cannot stat 'c-client/*.c': No such file or directory
cp: cannot stat 'c-client/c-client.a': No such file or directory
[root@hq scripts]#


The urls was wrong so I found a new url, so I change the script and here's the new one.

Code:
#!/bin/sh
# Script for PHP-IMAP installation. 0.1b
# Written by Martynas Bendorius (smtalk)

CWD=`pwd`
OS=`uname`

#Is it a 64-bit OS?
B64=0

B64COUNT=`uname -m | grep -c 64`
if [ "$B64COUNT" -eq 1 ]; then
    B64=1
    LD_LIBRARY_PATH=/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib
    export LD_LIBRARY_PATH
fi

if [ ! -e /usr/include/krb5.h ] && [ -e /etc/redhat-release ]; then
    echo "Installing krb5-devel"
    yum -y install krb5-devel
fi

VERSION=2007f
URL="https://www.mirrorservice.org/sites/ftp.cac.washington.edu/imap/imap-${VERSION}.tar.Z"
FILENAME=imap-${VERSION}
TARBALL=${FILENAME}.tar.Z

echo "Downloading ${TARBALL}..."
wget -O ${TARBALL} ${URL}
tar xzf ${TARBALL}
cd ${FILENAME}

echo "Installing ${FILENAME}..."

if [ ${OS} = "FreeBSD" ]; then
    if [ ${B64} -eq 0 ]; then
        make bsf
    else
        make bsf EXTRACFLAGS=-fPIC
    fi
else
    perl -pi -e 's#SSLDIR=/usr/local/ssl#SSLDIR=/etc/pki/tls#' src/osdep/unix/Makefile
    perl -pi -e 's#SSLINCLUDE=\$\(SSLDIR\)/include#SSLINCLUDE=/usr/include/openssl#' src/osdep/unix/Makefile
    perl -pi -e 's#SSLLIB=\$\(SSLDIR\)/lib#SSLLIB=/usr/lib/openssl#' src/osdep/unix/Makefile
    if [ ${B64} -eq 0 ]; then
        make slx
    else
        make slx EXTRACFLAGS=-fPIC
    fi
fi

echo "Copying files to /usr/local/php-imap"
mkdir -p /usr/local/php-imap/include
mkdir -p /usr/local/php-imap/lib
chmod -R 077 /usr/local/php-imap
cp -f c-client/*.h /usr/local/php-imap/include/
cp -f c-client/*.c /usr/local/php-imap/lib/
cp -f c-client/c-client.a /usr/local/php-imap/lib/libc-client.a
cd ..
rm -rf ${FILENAME}

if [ -d /usr/lib/x86_64-linux-gnu ] && [ ! -d /usr/kerberos/lib ]; then
    mkdir -p /usr/kerberos
    ln -s /usr/lib/x86_64-linux-gnu /usr/kerberos/lib
fi


exit 0;

The added this to configure.php* located at /usr/local/directadmin/custombuild/configure/fpm you need to add this to all the php v files that you want to enable php-imap.

--with-imap=/usr/local/php-imap \
--with-imap-ssl \


After that you need to rebuild you php

go to /usr/local/directadmin/custombuild

Execute command

./build php n

Then I get this error:

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

*** There was an error while trying to configure php. Check the configure file

I did change tis

--with-imap=/usr/local/php-imap \
--with-imap-ssl \

To this

--with-imap= \
--with-imap-ssl \


Still get the same error.

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

*** There was an error while trying to configure php. Check the configure file


Here is my configure.php*

This is php 7.0

Code:
#!/bin/sh
./configure \
	--prefix=/usr/local/php70 \
        --program-suffix=70 \
        --enable-fpm \
        --with-fpm-systemd \
        --with-config-file-scan-dir=/usr/local/php70/lib/php.conf.d \
        --with-curl \
        --with-gd \
        --enable-gd-native-ttf \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-freetype-dir=/usr/local/lib \
        --with-libxml-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mcrypt \
        --with-mhash \
        --with-mysql-sock=/var/lib/mysql/mysql.sock \
        --with-mysqli=mysqlnd \
        --with-pcre-regex=/usr/local \
        --with-pdo-mysql=mysqlnd \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-xsl \
        --with-zlib \
        --enable-zip \
        --with-iconv=/usr/local \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-sockets \
        --enable-soap \
        --enable-mbstring \
        --with-xmlrpc \
        --with-imap= \
        --with-imap-ssl \
        --with-icu-dir=/usr/local/icu \
        --enable-intl


This is php 7.1
Code:
#!/bin/sh
./configure \
	--prefix=/usr/local/php71 \
        --program-suffix=71 \
        --enable-fpm \
        --with-config-file-scan-dir=/usr/local/php71/lib/php.conf.d \
        --with-curl \
        --with-gd \
        --enable-gd-native-ttf \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-freetype-dir=/usr/local/lib \
        --with-libxml-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mcrypt \
        --with-mhash \
        --with-mysql-sock=/var/lib/mysql/mysql.sock \
        --with-mysqli=mysqlnd \
        --with-pcre-regex=/usr/local \
        --with-pdo-mysql=mysqlnd \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-xsl \
        --with-zlib \
        --enable-zip \
        --with-iconv=/usr/local \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-sockets \
        --enable-soap \
        --enable-mbstring \
        --with-xmlrpc \
        --with-imap= \
        --with-imap-ssl \
        --with-icu-dir=/usr/local/icu \
        --with-icu-dir=/usr/local/icu \
        --enable-intl

This is php 7.2

Code:
#!/bin/sh
./configure \
	--prefix=/usr/local/php72 \
        --program-suffix=72 \
        --enable-fpm \
        --with-fpm-systemd \
        --with-config-file-scan-dir=/usr/local/php72/lib/php.conf.d \
        --with-curl \
        --with-gd \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-freetype-dir=/usr/local/lib \
        --with-libxml-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mhash \
        --with-mysql-sock=/var/lib/mysql/mysql.sock \
        --with-mysqli=mysqlnd \
        --with-pcre-regex=/usr/local \
        --with-pdo-mysql=mysqlnd \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-sodium=/usr/local \
        --with-xsl \
        --with-zlib \
        --enable-zip \
        --with-iconv=/usr/local \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-sockets \
        --enable-soap \
        --enable-mbstring \
        --with-xmlrpc \
        --with-imap= \
        --with-imap-ssl \
        --with-icu-dir=/usr/local/icu \
        --enable-intl

This is php 7.3

Code:
#!/bin/sh
./configure \
	--prefix=/usr/local/php73 \
        --program-suffix=73 \
        --enable-fpm \
        --with-config-file-scan-dir=/usr/local/php73/lib/php.conf.d \
        --with-curl \
        --with-gd \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-freetype-dir=/usr/local/lib \
        --with-libxml-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mhash \
        --with-mysql-sock=/var/lib/mysql/mysql.sock \
        --with-mysqli=mysqlnd \
        --with-pcre-regex=/usr/local \
        --with-pdo-mysql=mysqlnd \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-sodium=/usr/local \
        --with-xsl \
        --with-zlib \
        --enable-zip \
        --without-libzip \
        --with-iconv=/usr/local \
        --enable-bcmath \
        --enable-calendar \
        --enable-ftp \
        --enable-sockets \
        --enable-soap \
        --enable-mbstring \
        --with-xmlrpc \
        --with-imap= \
        --with-imap-ssl \
        --with-icu-dir=/usr/local/icu \
        --with-icu-dir=/usr/local/icu \
        --enable-intl

Then I installed yum install libc-client-devel

Same still getting error.

Thanks
 
Hello,

Try:

Code:
yum -y install libc-client libc-client-devel uw-imap-static-2007f uw-imap-devel-2007f-4.el7.1.x86_64


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

ldconfig


then build PHP.
 
Last edited:
We use this for CentOS 7 (uw-imap-static is not available in yum):

Code:
cd /usr/local
wget -O imap-2007f.tar.gz https://www.mirrorservice.org/sites/ftp.cac.washington.edu/imap/imap-2007f.tar.gz
tar xvzf imap-2007f.tar.gz
cd imap-2007f
make lr5 EXTRACFLAGS=-fPIC
mkdir lib
mkdir include
cp c-client/*.c lib/
cp c-client/*.h include/
cp c-client/c-client.a lib/libc-client.a

add to configure.php*:

--with-imap-ssl \
--with-imap=\/usr\/local\/imap-2007f \
 
It is possible that your "=" sign on this line causes the configure script to not look in the right place. Try to remove the "=".

Code:
        --with-imap= \
 
We use this for CentOS 7 (uw-imap-static is not available in yum)

See:

Code:
# yum info uw-imap-static-2007f-16.el7.x86_64
Loaded plugins: etckeeper, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.transip.nl
 * epel: ftp.nluug.nl
 * extras: mirror.ams1.nl.leaseweb.net
 * updates: centos.mirror.transip.nl
Installed Packages
Name        : uw-imap-static
Arch        : x86_64
Version     : 2007f
Release     : 16.el7
Size        : 1.6 M
Repo        : installed
From repo   : epel
Summary     : UW IMAP static library
URL         : http://www.washington.edu/imap/
License     : ASL 2.0
Description : Contains static libraries for developing programs
            : which will use the UW C-client common API.
 
See:

Code:
# yum info uw-imap-static-2007f-16.el7.x86_64
Loaded plugins: etckeeper, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.transip.nl
 * epel: ftp.nluug.nl
 * extras: mirror.ams1.nl.leaseweb.net
 * updates: centos.mirror.transip.nl
Installed Packages
Name        : uw-imap-static
Arch        : x86_64
Version     : 2007f
Release     : 16.el7
Size        : 1.6 M
Repo        : installed
From repo   : epel
Summary     : UW IMAP static library
URL         : http://www.washington.edu/imap/
License     : ASL 2.0
Description : Contains static libraries for developing programs
            : which will use the UW C-client common API.

This is the EPEL repo, which is not installed on CentOS by default.
 
Yes, that's true. If you don't like it, you are free not to use it. For those who wants it, they can use it.:D
 
Back
Top