Page 1 of 3 123 LastLast
Results 1 to 20 of 46

Thread: HOWTO: PHP with IMAP support for CentOS6

  1. #1
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    220

    HOWTO: PHP with IMAP support for CentOS6

    I've pulled my hairs getting a proper working version of IMAP compiled within PHP. The trick was to compile the extension without issues. I wanted to get the latest version of IMAP.

    As such the way to go on CentOS 6.3 x86_64 (64 bits) was:

    Prepare the OS

    Code:
    yum install -y pam-devel libc-client libc-client-devel
    Install IMAP from source

    Code:
    wget ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz
    tar -zxvf imap-2007f.tar.gz
    cd imap-2007*
    make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd IP6=4
    echo "set disable-plaintext nil" > /etc/c-client.cf
    mkdir /usr/local/imap-2007f
    mkdir /usr/local/imap-2007f/include/
    mkdir /usr/local/imap-2007f/lib/
    chmod -R 077 /usr/local/imap-2007f
    rm -rf /usr/local/imap-2007f/include/*
    rm -rf /usr/local/imap-2007f/lib/*
    cp imapd/imapd /usr/sbin/
    cp c-client/*.h /usr/local/imap-2007f/include/
    cp c-client/*.c /usr/local/imap-2007f/lib/
    cp c-client/c-client.a /usr/local/imap-2007f/lib/libc-client.a
    and then add to /usr/local/directadmin/custombuild/custom/{ap1,ap2,suphp}/configure.phpX (where X is the version of PHP and either ap1, ap2 or suphp).

    Code:
    --with-imap-ssl=/usr/local/imap-2007f \
    --with-imap=/usr/local/imap-2007f \
    Hope this will help

    Credits: http://forum.eltechsupport.com/direc...tadmin-server/
    Last edited by Maniak; 01-08-2014 at 02:49 AM.
    Gregory A. | CTO Neocarrier Communications (AS48885)
    Tier-3 Data Centre Tier-1 Powered Connectivity Metro Ethernet
    Intensive Web Hosting VMware Private Cloud DDoS mitigation
    Network Integration Intensive Monitoring Managed Security

  2. #2
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Nice!
    Thanks for the How To...

  3. #3
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    6,773
    I was testing this how-to but apparently it doesnt work on my box.

    PHP fail on compile with this error:

    Code:
    /usr/bin/ld: /usr/local/imap-2007f/lib/libc-client.a(osdep.o): relocation R_X86_64_32 against `server_input_wait' can not be used when making a shared object; recompile with -fPIC
    /usr/local/imap-2007f/lib/libc-client.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [libphp5.la] Error 1
    make: *** Waiting for unfinished jobs....
    /usr/local/imap-2007f/lib/libc-client.a(osdep.o): In function `ssl_onceonlyinit':
    /usr/local/crazynetwork/imap-2007f/c-client/osdep.c:337: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
    Any hint?

    Regards
    SeLLeRoNe - Andrea Iannucci
    Head of Managed Service - Senior DevOps Engineer
    If you need my support write me an E-Mail to Support@CrazyNetwork.it

  4. #4
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    7,446
    Give it a try (place the code in "setup-imap.sh" and execute it then):
    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=2006k
    URL="ftp://ftp.cac.washington.edu/imap/old/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;
    Run the script, then add to configure.php*:
    Code:
    --with-imap=/usr/local/php-imap \
    --with-imap-ssl \
    And rebuild PHP.
    Last edited by smtalk; 11-06-2014 at 02:21 PM. Reason: Added a note about sh script
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

  5. #5
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    6,773
    It worked fine,

    Thanks

    Regards
    SeLLeRoNe - Andrea Iannucci
    Head of Managed Service - Senior DevOps Engineer
    If you need my support write me an E-Mail to Support@CrazyNetwork.it

  6. #6
    Join Date
    Oct 2006
    Location
    Allen, TX
    Posts
    228
    As always and expected, Martynas, your solution worked great!

    Quote Originally Posted by smtalk View Post
    Give it a try:
    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=2006k
    URL="ftp://ftp.cac.washington.edu/imap/old/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}
    
    exit 0;
    Run the script, then add to configure.php*:
    Code:
    --with-imap=/usr/local/php-imap \
    --with-imap-ssl \
    And rebuild PHP.

  7. #7
    Join Date
    Jun 2012
    Posts
    629
    so create a file (lets say imap.sh) containing this info and put it in directadmin/scripts and run it is all we need to do?
    then add lines to php as needed of course.
    if so would be nice to have that in the /scripts already, was surprised to see no imap upon install.
    edit: should clarify, I mean no mention of imap. I know DA itself is imap capable.
    sorry about phrasing that badly.
    Last edited by dmacleo; 05-11-2013 at 05:20 PM.

  8. #8
    Join Date
    Jan 2013
    Posts
    8
    I've tried this but I am getting the following error:

    ./imap.sh: /bin/sh^M: bad interpreter: No such file or directory

  9. #9
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    7,446
    It looks like you have DOS characters in your file. Try opening the file with "nano -N", you should notice the difference.
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

  10. #10
    Join Date
    Jun 2013
    Posts
    1
    Quote Originally Posted by smtalk View Post
    Give it a try:
    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=2006k
    URL="ftp://ftp.cac.washington.edu/imap/old/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}
    
    exit 0;
    Run the script, then add to configure.php*:
    Code:
    --with-imap=/usr/local/php-imap \
    --with-imap-ssl \
    And rebuild PHP.
    Why are you using version 2006k and not something newer?
    I would like to use this solution, as stated it seems to work for people, but before I put this in production, I need to be sure I can use it.
    All other solutions suggested by DirectAdmin do not work at all.

    BTW: I am not using BSD or CentOS, but Ubuntu, so I need to rewrite it anyway.

  11. #11
    Join Date
    Oct 2006
    Location
    Allen, TX
    Posts
    228
    I know you can change the reference of 2006k to the newest version and it will work.

  12. #12
    Join Date
    Mar 2013
    Posts
    34
    hello
    i do it
    nano 1.sh
    then put code on it, then ctrl + X
    then sh 1.sh
    but i see it freeze on Installing Imap-2006k...

    it is normall? i must wait?

    OS: centos 5.8 32bit

    Thanks.

  13. #13
    Join Date
    Apr 2009
    Posts
    2,232
    I consider to install imap for php, however I don't understand why you can't just use the guide from DirectAdmin? It is here: http://www.directadmin.com/imap.txt

    It is linked to from here: http://help.directadmin.com/item.php?id=341

    So the above guide will not work on CentOS 6.4 64bit?

    Edit: Also I see that I do not have /usr/lib/dovecot/imap , it does not exist. So I need to install IMAP then?
    Last edited by ditto; 12-06-2013 at 04:22 AM.

  14. #14
    Join Date
    Apr 2009
    Posts
    2,232
    I am ready to try smtalk script, but don't want the old imap version. Is there any reason you can't use the newest version imap-2007f?

    Changelog: http://www.washington.edu/imap/docum.../RELNOTES.html

    Download: ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz

    Site: http://www.washington.edu/imap/

    Edit: I think it is better to install imap manually from source instaed of smtalk script, so that I have more control. Anybody done it before and have insights?
    Last edited by ditto; 12-06-2013 at 04:58 AM.

  15. #15
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    6,773
    In smtalk script change VERSION to 2007f
    and change URL to become:
    URL="ftp://ftp.cac.washington.edu/imap/imap-${VERSION}.tar.Z"

    Done, that will put 2007 version and it is compiled.. as it was the old one...

    Regards
    SeLLeRoNe - Andrea Iannucci
    Head of Managed Service - Senior DevOps Engineer
    If you need my support write me an E-Mail to Support@CrazyNetwork.it

  16. #16
    Join Date
    Apr 2009
    Posts
    2,232
    Yes, I think I can try that. However I still don't like to use the script, but would like more control and do it manually. I study this page I found now: http://thedirectadmin.com/?p=15

  17. #17
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    6,773
    I suppose you does use custombuild as everyone else, so, where is the difference? If smtalk is trusteable with that why would not be with php-imap?

    Also, that doesnt apply any modify and just do all the commands you would need to do manually, and, it still require you to use custom configure.php5 file to implement and recompile php with IMAP, in fact, that just prepare the require libraries in a specific folder, no server-wide messup, once you wanna remove that, just remove the dedicated folder.

    Regards
    SeLLeRoNe - Andrea Iannucci
    Head of Managed Service - Senior DevOps Engineer
    If you need my support write me an E-Mail to Support@CrazyNetwork.it

  18. #18
    Join Date
    Apr 2009
    Posts
    2,232
    Regarding smtalk script, first I get the error:

    Code:
    -bash: /root/setup-imap.sh: /bin/sh^M: bad interpreter: No such file or director
    I fix that by adding a space in the first line between # and !/bin/sh so othat it becomes like this:

    Code:
    # !/bin/sh
    Then I get this error:

    Code:
    [root@server~]# /root/setup-imap.sh
    : command not found: line 4:
    : command not found: line 7:
    : command not found: line 10:
    /root/setup-imap.sh: line 63: syntax error: unexpected end of file
    [root@server~]#
    @smtalk, would you bee so kind to just add the commands needed to manually do this on CentOS 6.4 64bit without using your script?

    Edit: I removed the empty line space in line 4, 7 and 10, and now I only get this error:

    Code:
    [root@server~]# /root/setup-imap.sh
    /root/setup-imap.sh: line 60: syntax error: unexpected end of file
    [root@server~]#
    Last edited by ditto; 12-06-2013 at 06:59 AM.

  19. #19
    Join Date
    Apr 2009
    Posts
    2,232
    I already is using a custom folder for php in custombuild, no problem. I only wanted more control by doing the comands manually, because the script is dynamic for many systems, and as I said I want more control by doing it manually.

    However I have been trying to use the script, but as you can see in my previous post, I am not able to run it without errors.

  20. #20
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    7,446
    ditto, you must have been using MS Windows to save the script and upload it to the server. This way you have ^M characters in your file (open it with "nano -N" and you'll notice them). Please copy the code directly to the server, or use dos2unix tool to convert your current text file. That is very simple to do that (dos2unix /root/setup-imap.sh and that's it), you may use sed as an alternative to it, if you'd like to.
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 18
    Last Post: 04-25-2010, 06:19 AM
  2. howto contact support team
    By asifbhura in forum DNS
    Replies: 3
    Last Post: 02-26-2010, 11:04 AM
  3. HOWTO: Secure POP3/SMTP/IMAP over SSL
    By martinfst in forum How-To Guides
    Replies: 11
    Last Post: 10-22-2008, 09:03 PM
  4. HowTo Setup Imap.
    By milan in forum E-Mail
    Replies: 6
    Last Post: 02-23-2007, 07:16 AM
  5. HOWTO: Convert to courier imap using mysql
    By ballyn in forum How-To Guides
    Replies: 81
    Last Post: 12-26-2005, 06:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •