简体   繁体   English

在PHP中使用imap函数而无需重建和重新安装

[英]Using imap functions in PHP without rebuilding and reinstalling

I wanted the latest PHP version to work with on a fresh Macbook, but the php installation does not include imap functions by default. 我想在最新的Macbook上使用最新的PHP版本,但是php安装默认情况下不包含imap函数。 There is one specific function I need - namely the "imap_rfc822_parse_headers" function, but I don't feel like recompiling, building and installing PHP (not to mention the effort it takes to install c-client and imap.so beforehand) just for that. 我需要一个特定的功能 - 即“imap_rfc822_parse_headers”功能,但我不想重新编译,构建和安装PHP(更不用说为事先安装c-client和imap.so所花费的精力) 。 I fear that the convoluted procedures (of which each that I've found is somewhat different) might mess up my current installation which was by no means easy to set up. 我担心复杂的程序(我发现每个程序有些不同)可能会搞砸我当前的安装,这绝不容易设置。

Is there any other, easier way of installing imap into PHP? 有没有其他更简单的方法将imap安装到PHP中? On a related note, is there perhaps a class-based alternative to the function I need? 在一个相关的说明中,是否可能有一个基于类的替代我需要的功能?

I've finally found the solution. 我终于找到了解决方案。 Most of it was here: http://www.september28.co.uk/blog/2011/11/24/php-imap-support-in-mac-os-x-lion-without-recompiling-php/ 其中大部分都在这里: http//www.september28.co.uk/blog/2011/11/24/php-imap-support-in-mac-os-x-lion-without-recompiling-php/

My machine is a late 2011 Macbook Pro with MacOSX 10.7.4, PHP 5.4. 我的机器是2011年末的Macbook Pro,配备MacOSX 10.7.4,PHP 5.4。 installed via these instructions: http://www.hirmet.com/mac-os-x-lion-upgrade-to-php-5-4 通过以下说明安装: http//www.hirmet.com/mac-os-x-lion-upgrade-to-php-5-4

Here's a step-by-step for those with a similar or identical setup: 对于那些具有相似或相同设置的人来说,这是一步一步的:

Download the imap source from this url, focus on the one with the most recent date which doesn't end in "Z": ftp://ftp.cac.washington.edu/imap/ 从这个url下载imap源代码,关注最近日期不以“Z”结尾的那个: ftp//ftp.cac.washington.edu/imap/

Unarchive, go into folder, run the following commands: 取消归档,进入文件夹,运行以下命令:

$ make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"

The above command will throw a bunch of warnings at you, but should complete sucessfully, unlike the command originally suggested in the september28 blog post. 上面的命令会向你发出一堆警告,但应该成功完成,这与september28博客文章中最初建议的命令不同。

Next, do the following: 接下来,执行以下操作:

$ 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

Once this is done, go into the downloaded php source folder if you made a custom upgrade like I did (as per the second link in the answer) and build the imap.so extension for your system. 完成后,如果您像我一样进行自定义升级(根据答案中的第二个链接),请进入下载的php源文件夹,并为您的系统构建imap.so扩展。 If you didn't build a custom version, just download the PHP source for the version you have installed, and use that, it doesn't matter. 如果您没有构建自定义版本,只需下载已安装版本的PHP源代码,并使用它,这无关紧要。

$ cd ~/Downloads/Php-5.4.4/ext/imap
$ phpize
$ ./configure --with-imap==/usr/local/imap-2007 --with-kerberos --with-imap-ssl
$ make

Once done, do the following: 完成后,请执行以下操作:

$ sudo cp modules/imap.so /usr/lib/php/extensions/no-debug-non-zts-20100525/

...or if your PHP extension folder is different, put that (you can see the location in phpinfo(); ) ...或者如果您的PHP扩展文件夹不同,请将其放入(您可以在phpinfo()中看到该位置;)

Restart apache and you should be ready to go. 重启apache,你应该准备好了。

$ sudo apachectl restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM