Topic : Update PHP with IMAP

Topic Archived This topic has been archived - replies are not allowed.


This question is answered. "Helpful" answers available: 1 . "Solved" answers available: 1 .



            Permlink
            Replies : 14 - Pages : 1 - Last Post : May 24, 2007 8:53 AM by: Rob Reuland
Rob Reuland


Posts: 162
Registered: May 28, 2003
Update PHP with IMAP
Posted: May 22, 2007 4:56 PM
 

I've just installed phplist (http://www.phplist.com/), which is a newsletter mailer based on php. Some of the features require that IMAP be installed with the php installation. Evidently Apple's OSX install does not include IMAP in PHP by default, but presumably IMAP can be added if PHP is recompiled. (See http://www.php.net/manual/en/ref.imap.php). I was planning on updating PHP using Alex's very helpful tutorial, available at http://osx.topicdesk.com/content/category/4/18/62/, and at the same time adding IMAP.

Altho Alex does not touch on IMAP in his tutorial, I believe that to includ IMAP in the PHP installation, the configuration string must include "--with-imap-ssl=/sw --with-imap=/usr/share/c-client", or something similar. In any event, it seems that "c-client" does not live in /usr/share nor anywhere on my system, so I have not attempted an installation so far.

Does anyone know how to update/recompile PHP to include IMAP? And if "c-client" is required, how do I intall that first?

Lost count   Mac OS X (10.4.9)  
pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 22, 2007 11:22 PM   in response to: Rob Reuland
 

c-client is not installed and if you want it, you must install it seperately. I have never had a need for it, so I don't have it on my server. Most likely there are instructions included with the source file:
ftp://ftp.cac.washington.edu/imap/

--with-imap-ssl=DIR will do (instead of DIR you must substitute with the c-client installation directory.

  Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 7:46 AM   in response to: pterobyte
 

Thanks ptero

Couple questions before i mess everything up . . .

Recompiling PHP to include IMAP seems straightforward, but the sticker is that "c-client" is required beforehand.

I dl'd "c-client.tar.z" from ftp://ftp.cac.washington.edu/imap/ and expanded it. It seems to contains an entire IMAP environment, which I don't need. Inside /src/client of the expanded folder are several .h and .c files. As I read the instructions here http://www.php.net/manual/en/ref.imap.php it appears that these files need to be copied into a new director inside /usr/share on my server.

To install "c-client," therefore, I simply mkdir'd a folder named "imap-2006h" inside /usr/share and also created two sub-directories, "include" and "lib". Into these I copied the .h and .c files respectively and fixed permissions. Is OK to do, or should I somehow have compiled them first?

Assuming this is all that's necessary to install c-client, I plan to update PHP using your tutorial and recompile with IMAP included. To do so, I will use the standard configuration string, except that near the end I will include "--with-imap=/usr/share/imap-2006h". Sound all right?

Should I also add "--with-imap-ssl=/usr/share/imap-2006h"?

Lost count   Mac OS X (10.4.9)  
pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 23, 2007 7:59 AM   in response to: Rob Reuland
 

For c-client, I'll have to look into it. If they only need the headers, then you are probably fine. I do suspect that is not the case though.

Assuming this is all that's necessary to install
c-client, I plan to update PHP using your tutorial
and recompile with IMAP included. To do so, I will
use the standard configuration string, except that
near the end I will include
"--with-imap=/usr/share/imap-2006h". Sound all
right?

Yes.

Should I also add
"--with-imap-ssl=/usr/share/imap-2006h"?

If you need SSL, then yes.

  Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 8:04 AM   in response to: pterobyte
 

The contents file states that these are "pre-processed c-client sources", which I assumed meant they did not need to be compiled . . . or I hope that's what it means, as I've no idea how to compile them!

Lost count   Mac OS X (10.4.9)  
pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 23, 2007 8:34 AM   in response to: Rob Reuland
Helpful

Try this:

sudo mkdir -p /SourceCache
cd /SourceCache
sudo curl -o ftp://ftp.cac.washington.edu/imap/imap.tar.Z
sudo tar xzf imap.tar.Z
cd imap-2006h
sudo make bsf SSLTYPE=none
(If above doesn't work try:
sudo make oxp SSLTYPE=none
)

(you don't need SSL, since PHPList and the mailserver are on the same machine anyway)

Ignore all errors and DO NOT issue make install, you don't want another IMAP server on your machine. You just want the c-client library to be compiled.

Next follow the PHP tutorial and add:
--with-imap=/SourceCache/imap-2006h

to the configuration string.

Haven't done any extensive testing, just looked at the source files. However you don't risk anything. If it breaks you will know while configuring PHP and before actually installing it. It'll show something like "configure: error: Cannot find imap library (libc-client.a)"

HTH,
Alex

  Mac OS X (10.4.9)  

Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 9:15 AM   in response to: pterobyte
 

Alex -- OK, I did all this, short of updating PHP, and everything seems to have compiled nicely in SourceCache using make bsf, altho it did throw a bunch of errors. (Also should be curl -O, not curl -o to download, eh?)

Since SourceCache is a temporary directory, I think I should move the c-client files to /usr/share. Also, I think this is necessary for PHP to install with IMAP. This is from PHP.net:

"It's important that you do not copy the IMAP source files directly into the system include directory as there may be conflicts. Instead, create a new directory inside the system include directory, such as /usr/local/imap-2000b/ (location and name depend on your setup and IMAP version), and inside this new directory create additional directories named lib/ and include/. From the c-client directory from your IMAP source tree, copy all the *.h files into include/ and all the *.c files into lib/. Additionally when you compiled IMAP, a file named c-client.a was created. Also put this in the lib/ directory but rename it as libc-client.a."

So, I gather I must create /usr/shar/imap-200h with the two sub-directories lib and include (already done) and copy the .c and .h files into them BEFORE I go about updating PHP?

Thanks for looking at this!

Lost count Mac OS X (10.4.9)

Lost count   Mac OS X (10.4.9)  
pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 23, 2007 9:34 AM   in response to: Rob Reuland
 

Yes it should be -O sorry for the typo.

In theory, everything you said sound right. As I said, I haven't tried it, but you're on the right track.

Alex

  Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 12:44 PM   in response to: pterobyte
 

Couple problems: the instructions state "Additionally when you compiled IMAP, a file named c-client.a was created. Also put this in the lib/ directory but rename it as libc-client.a." This file "c-client.a" does not exist, at least in SourceCache/imap-2006h.

From SourceCache/imap-2006h/src/c-client, I copied all the *.h files and *.c files into /usr/share/imap-2006h/include and */lib respectively.

When I ran the configure string after downloading the update, however, it returned this fatal error:

checking for IMAP support... yes
checking for IMAP Kerberos support... /usr
checking for IMAP SSL support... no
checking for utf8_mime2text signature... new
checking for U8T_CANONICAL... no
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
sh-2.05b$

U8T_CANONICAL seems to relate to c-client, tho not sure how.

This is what the config log shows:

; return 0; }
configure:44781: checking for U8T_CANONICAL
configure:44797: gcc -c -I/usr/share/imap-2006h/include -no-cpp-precomp conftest.c 1>&5
In file included from /usr/share/imap-2006h/include/c-client.h:41,
from configure:44788:
/usr/share/imap-2006h/include/mail.h:1497:21: error: linkage.h: No such file or directory
In file included from configure:44788:
/usr/share/imap-2006h/include/c-client.h:42:48: error: osdep.h: No such file or directory
In file included from /usr/share/imap-2006h/include/c-client.h:48,
from configure:44788:
/usr/share/imap-2006h/include/misc.h:52: error: parse error before 'size_t'
/usr/share/imap-2006h/include/misc.h:52: warning: no semicolon at end of struct or union
/usr/share/imap-2006h/include/misc.h:54: error: parse error before '}' token
/usr/share/imap-2006h/include/misc.h:99: error: parse error before 'size'
configure: failed program was:
#line 44786 "configure"
#include "confdefs.h"

#include <c-client.h>

int main() {

int i = U8T_CANONICAL;

; return 0; }

Very annoying, eh?

Lost count Mac OS X (10.4.9)

Lost count   Mac OS X (10.4.9)  

pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 23, 2007 12:53 PM   in response to: Rob Reuland
 

Could it be you are trying to build PHP5 instead of PHP4?
If yes, try 4

  Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 1:19 PM   in response to: pterobyte
 

No, I'm using 4.4.7, which is the latest stable build. I wonder if I should reinstall 4.4.4, which I'm currently running.

Lost count   Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 1:31 PM   in response to: Rob Reuland
 

Perhaps an answer . . . after compiling, two c-client folders were created, one inside /imap-2006h and the other inside /imap-2006h/src. As the instructions called for the transfer of .c and .h files "from the IMAP source tree", I only transferred those inside the /src directory, of which there were 36. The c-client folder inside the main directory, however, contains 257 files, including those that config.log reports as MIA, triggering the error discussed above.

Lost count   Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 23, 2007 7:38 PM   in response to: Rob Reuland
 

Disregard last post--that was a non-starter, but I think I have a successful installation, which I will post here as the documentation on this from php and from phplist is pretty bad:

First get and compile the c-client library, which is necessary for those wanting to run phplist:

sudo mkdir -p /SourceCache
cd /SourceCache
sudo curl -O ftp://ftp.cac.washington.edu/imap/c-client.tar.Z
sudo tar xzf c-client.tar.Z
cd imap-2006h
sudo make oxp
sudo mkdir lib
sudo mkdir include

Next open /SourceCache/c-client and drag all the */.h files (including the aliases) into “include.” Then drag all the */.c files (aliases too) into “lib”.

Find “c-client.a” and change name to "libc-client.a" and place in the lib folder.

Correct permissions on lib and include.

Finally install php (cheers to Alex) as follows:

cd /SourceCache
sudo curl –O http://us.php.net/distributions/php-4.4.7.tar.gz
sudo tar xzpf php-4.4.7.tar.gz
cd /SourceCache/php-4.4.7
sh
CFLAGS=-DBIND_8_COMPAT
export CFLAGS

sudo ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --with-apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql=/usr --with-mysql-sock=/var/mysql/mysql.sock --with-imap=/SouceCache/imap-2006h --without-pear

sudo make
sudo make install
sudo apachectl graceful restart
exit

One last question, Alex: can I safely delete the SourceCache folder now that the installation is complete? My only concern is that the config string points to items in the folder, and I'm wondering whether I ought to have placed them inside /usr/share instead of SourceCache, or doesn't it make a difference?

Lost count Mac OS X (10.4.9)

Lost count   Mac OS X (10.4.9)  

pterobyte


Posts: 5,575
From: Switzerland
Registered: May 19, 2005
Re: Update PHP with IMAP
Posted: May 23, 2007 10:42 PM   in response to: Rob Reuland
 

One last question, Alex: can I safely delete the
SourceCache folder now that the installation is
complete? My only concern is that the config string
points to items in the folder, and I'm wondering
whether I ought to have placed them inside /usr/share
instead of SourceCache, or doesn't it make a

No you can't at this point. Seems like it doesn't only need the headers, but references the compiled library.

Your best bet is to copy what is needed into
/usr/local/include
/usr/local/lib

The run the configure command for PHP again (change the path to point to /usr/local).

If all is well, you can delete /SourceCache (although I'd keep it. If tomorrow you need to re-install PHP with other features, it's already there (or if an Apple update should overwrite something you just do "make install" and are up and running again).
No matter whether you keep SourceCache or not, I'd still move the c-client stuff for consistency.

It may not work if for some reason it references it's build directory (haven't had the time to look at the Makefile properly). But it's a 5 minute job worth a try. :-)

  Mac OS X (10.4.9)  
Rob Reuland


Posts: 162
Registered: May 28, 2003
Re: Update PHP with IMAP
Posted: May 24, 2007 8:53 AM   in response to: pterobyte
 

OK, I re-compiled imap-2006h inside /usr/local and moved the c-client files as detailed above. I re-installed php with the new location for imap and all seems to be working :-)

Thanks once again.

Lost count   Mac OS X (10.4.9)