macbook lion安装php imap扩展【转】

1. 下载IMAP

Extract the tar.gz file (double click it in finder or tar xvzf imap-2007f.tar.gz in terminal)
Then, modified from This Comment on the same xeonxai blog post, do the following to avoid the error:
“configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.” when executing item 6 in this tutorial.
cd ~/Downloads/imap-2007f
make osx EXTRACFLAGS=”arch i386 -arch X86_64 -g -Os -pipe -no-cpp-precomp”
sudo cp c-client/*.h /usr/local/include/
sudo cp c-client/*.c /usr/local/lib/
sudo cp c-client/c-client.a /usr/local/lib/libc-client.a
Then download php source. Make sure you get the right source (you can check your php version by the command in the terminal: php -r “phpinfo();” I think OS X Lion standard install is php 5.3.6 which you can download at
Unpack php-5.3.6.tar.bz2 (double click it in finder or tar xvzf php-5.3.6.tar.bz2)
In Terminal:
cd ~/Downloads/php-5.3.6/ext/imap
./configure –with-imap==/usr/local/imap-2007 –with-kerberos –with-imap-ssl
At the make command, things will fail. This is the message that I got…
In file included from /Users/danspencer/Downloads/php-5.3.6/ext/imap/php_imap.c:44:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /Users/danspencer/Downloads/php-5.3.6/ext/imap/php_imap.c:44:
/usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
make: *** [php_imap.lo] Error 1
Basically, pcre is not installed, so we need to install this first. See next step!
Modified from
Download PCRE from the Sourceforge Project page:
Untar the file: tar xvzf pcre-8.20.tar.gz
cd to the directory: cd pcre-8.20
configure and make: .configure –prefix=/usr/local
sudo make install
Successful installation should look like the following in the last couple of lines:
test -z “/usr/local/include” || ./install-sh -c -d “/usr/local/include”
/usr/bin/install -c -m 644 pcre.h pcrecpparg.h pcre_stringpiece.h ‘/usr/local/include’
test -z “/usr/local/lib/pkgconfig” || ./install-sh -c -d “/usr/local/lib/pkgconfig”
/usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcrecpp.pc ‘/usr/local/lib/pkgconfig’
Now you should be able to cd to the imap extension directory in php-5.3.6 source and compile the extension:
cd ~/Downloads/php-5.3.6/ext/imap
./configure –with-imap==/usr/local/imap-2007 –with-kerberos –with-imap-ssl
sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20090626/
Now edit php.ini (sudo vi /etc/php.ini) and add the imap extension in (I added mine around line 990, just under the commented out windows extensions. in vi, you will need to press i to insert text):
;IMAP Extension
After editing, save the file (in vi press esc to exit insert mode, then type “:x”).
now restart apache, and we should be done! sudo apachectl graceful
To test to see if we are up and running, we can do a couple of things…
php -r “phpinfo();”
We should be able to find the following in the output (the modules are in alphabetical order):
IMAP c-Client Version => 2007f
SSL Support => enabled
Kerberos Support => enabled

You can also check to see if the imap functions exist:
php -r “if(function_exists(‘imap_open’)) { echo ‘imap_open exists!’; } else { echo ‘imap_open does not exist’; }”
You should get an output of “imap_open exists”
So that’s it, hope it helps!



电子邮件地址不会被公开。 必填项已用*标注