Board logo

标题: lnmp之安装PHP模块(不需要重装PHP) [打印本页]

作者: licess    时间: 2010-8-18 09:39     标题: lnmp之安装PHP模块(不需要重装PHP)

VPS侦探一直在努力的去营造一个VPS相关话题的交流环境,于是有了很多的VPS相关的教程、QQ群、有了论坛、有了LNMP一键安装包...
VPS侦探主要根据论坛上lnmp版块用户反映来写一些教程,今天说一下如何为lnmp的php安装一些自己需要的模块
本文以imap和exif模块为例。

本处不再提供更新,最新请到:https://www.vpser.net/manage/lnmp-php-install-ext.html 查看最新的

一、安装imap模块
1、安装imap模块前需要先安装imap所需的库:

CentOS :yum install libc-client-devel
Debian:apt-get install libc-client-dev

2、首先进入php安装目录的ext目录
比如php的安装目录为:/root/lnmp0.4-full/php-5.2.10/
则执行:cd /root/lnmp0.4-full/php-5.2.10/ext/
我们要安装imap模块,执行cd imap/

再执行 /usr/local/php/bin/phpize 会返回如下信息:
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519

再执行以下命令:
[root@vpser imap]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@vpser imap]# make && make install

执行完返回:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

表示已经成功,再修改/usr/local/php/etc/php.ini
查找:extension = 再最后一个extension= 后面添加上extension = "imap.so"
保存,执行/root/lnmp restart 重启。

在浏览器里面输入http://ip/p.php,打开探针,安装IMAP模块前:


安装IMAP模块后:


二、安装exif模块安装exif不需要另外安装库,所以省略掉了安装库的步骤。

比如php的安装目录为:/root/lnmp0.4-full/php-5.2.10/
则执行:cd /root/lnmp0.4-full/php-5.2.10/ext/
我们要安装exif模块,执行cd exif/
再执行 /usr/local/php/bin/phpize 会返回如下信息:

Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519

再执行以下命令:
[root@vpser imap]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@vpser imap]# make && make install

执行完返回:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

表示已经成功,再修改/usr/local/php/etc/php.ini

查找:extension = 再最后一个extension= 后面添加上extension = "exif.so"
保存,执行/root/lnmp restart 重启。

在/home/wwwroot/下面创建一个exif.php的文件,内容如下:
<?php
$exif = read_exif_data ('IMG_0001.JPG');
while(list($k,$v)=each($exif)) {
echo "$k: $v<br>\n";
}
?>
其中IMG_0001.JPG为照片文件。

未安装exif模块前:


安装exif模块后:


可以读出照片的exif信息。

安装其他模块也基本上都是这两种方式,当./configure --with-php-config=/usr/local/php/bin/php-config 执行这个的时候是会检查系统上库是否安装上,如果没有安装上就会报错,按错误提示安装相关的库就行。

如果还有其他问题,可以到https://bbs.vpser.net提问,记得提问前在[url=search.php]https://bbs.vpser.net/search.php[/url]搜索一下哦。
作者: jakashop    时间: 2010-10-17 09:11

我在安裝一、安装imap模块,
執行[root@vpser imap]# make && make install

出現訊息:make: *** No targets specified and no makefile found.  Stop.

無法動作...
請站長指點一下,謝謝!!



作者: zjpacai521    时间: 2010-12-27 20:24

checking for utf8_mime2text signature... new
checking for U8T_DECOMPOSE...
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
xylz:~/lnmp0.5-full/php-5.2.14/ext/imap# make && make install
make: *** No targets specified and no makefile found.  Stop.
xylz:~/lnmp0.5-full/php-5.2.14/ext/imap#

出现这样的错误,就安装不了了,可以帮我看看吗
作者: shli    时间: 2011-1-25 19:41

我的也是。
#make && make install

make: *** No targets specified and no makefile found.  Stop.
作者: 等你唯一    时间: 2011-2-6 20:52

# ./configure --with-php-config=/usr/local/php/bin/php-config
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/php/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking for IMAP support... yes, shared
checking for IMAP Kerberos support... no
checking for IMAP SSL support... no
checking for utf8_mime2text signature... old
checking for U8T_DECOMPOSE...
checking for pam_start in -lpam... no
checking for crypt in -lcrypt... yes
configure: error: This c-client library is built with Kerberos support.

      Add --with-kerberos to your configure line. Check config.log for details.

#make && make install

make: *** No targets specified and no makefile found.  Stop.

请军大帮忙看看吧,谢谢了
作者: licess    时间: 2011-2-10 09:02     标题: 回复

@IP jakashop 肯定是configure哪一步出错了。


IP shli  肯定是configure哪一步出错了。

@IP 等你唯一  configure 那步执行完报错了。configure: error: This c-client library is built with Kerberos support.
Add --with-kerberos to your configure line. Check config.log for details.
在编译参数上加上--with-kerberos 试试,如果不报错再make
作者: 9eku    时间: 2011-3-15 22:45

make && make install
到这里就报错

[root@WebServer imap]# make && make install
make: *** 没有指明目标并且找不到 makefile。 停止。
作者: mmdmm    时间: 2011-6-24 11:41

感谢分享
作者: liyunlong    时间: 2011-6-24 12:07

好方法。今天是受教了。谳谢。。。
作者: dafeiji    时间: 2011-10-3 14:07

帮顶军歌

[ 本帖最后由 dafeiji 于 2011-11-9 23:21 编辑 ]
作者: version919    时间: 2011-12-1 01:01     标题: LNMPA 如何设置才能安装PHP的SNMP和LDAP 模块

本人在ubuntu上安装了LNMPA,现在想加载SNMP和LDAP模块,请问该如何设置?谢谢。
作者: lovegx999    时间: 2012-2-17 11:21

这个方法不错
作者: zy2060537    时间: 2012-2-18 02:01     标题: 回复 6# 的帖子

--with-kerberos
这个要在哪里加上?如何加上
./configure --with-php-config=/usr/local/php/bin/php-config--with-kerberos
这样??
作者: licess    时间: 2012-2-18 09:25

少了一个空格
作者: zy2060537    时间: 2012-2-18 12:36     标题: 回复 14# 的帖子

./configure --with-php-config=/usr/local/php/bin/php-config--with -kerberos

[root@gg ext]# ./configure --with-php-config=/usr/local/php/bin/php-config--with -kerberos
-bash: ./configure: No such file or directory
作者: zy2060537    时间: 2012-2-18 12:36     标题: 回复 14# 的帖子

./configure --with-php-config=/usr/local/php/bin/php-config--with -kerberos

[root@gg ext]# ./configure --with-php-config=/usr/local/php/bin/php-config--with -kerberos
-bash: ./configure: No such file or directory
显示这个
作者: licess    时间: 2012-2-18 15:53     标题: 回复 16# 的帖子

没进对目录,没输对命令
作者: zy2060537    时间: 2012-2-18 16:41

./configure --with-php-config=/usr/local/php/bin/php-config--with -kerberos
configure: error: unrecognized option: -kerberos
Try `./configure --help' for more information.
作者: licess    时间: 2012-2-18 18:26

都说过一次了,没输对参数,加空格肯定是加在参数的前面,能把一个参数分成2块吗
而且,你输错了,也已经提示了。
./configure --with-php-config=/usr/local/php/bin/php-config --with-kerberos
作者: zy2060537    时间: 2012-2-18 19:11

-bash: ./configure: No such file or directory
./configure --with-php-config=/usr/local/php/bin/php-config --with-kerberos 按你说的这个输入后显示上面的问题呢
这些我都是不懂的,也都是直接按照说明操作的,所以你说的那些我都不懂的
作者: vabcv    时间: 2012-7-27 06:15     标题: 回复 6# 的帖子

[root@VABCV imap]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-kerberos
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/php/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for IMAP support... yes, shared
checking for IMAP Kerberos support... yes
checking for IMAP SSL support... no
checking for utf8_mime2text signature... old
checking for U8T_DECOMPOSE...
checking for pam_start in -lpam... no
checking for crypt in -lcrypt... yes
checking for krb5-config... /usr/kerberos/bin/krb5-config
configure: error: This c-client library is built with SSL support.

      Add --with-imap-ssl to your configure line. Check config.log for details.
      
[root@VABCV imap]# make && make install
make: *** No targets specified and no makefile found.  Stop.
[root@VABCV imap]#

还是报错啊!!
作者: hidashu    时间: 2013-11-22 15:49

军哥写一下安装curl的详细步骤,需不需要安装库?我安装的时候,php.ini去掉注释那句,就提示需要库什么的
作者: licess    时间: 2013-11-22 20:03     标题: 回复 22# 的帖子

curl 本来就有,可以自己看phpinfo

php.ini就是安装其他模块或组件也不需要去掉里面的注释,都是添加.so 的配置

完全就是依教程类推,编译时提示缺什么就再装什么
作者: popwool    时间: 2014-2-3 15:17

我的经验:
第一次,刚开始就错在编译上
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
解决办法:
在确实libc-cleint 已经安装成功的前提下,做一个链接,ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
第二次,执行,增加--with -kerberos
configure: error: This c-client library is built with SSL support.

      Add --with-imap-ssl to your configure line. Check config.log for details.
第三次,执行,./configure --with-php-config=/usr/local/php/bin/php-config --with-imap-ssl --with-kerberos
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

开始MAKE    #make && make install
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
作者: popwool    时间: 2014-2-3 15:29

[root@x-phpFAQ-01 imap]# make test

Build complete.
Don't forget to run 'make test'.


+--------------------------------------------------------------+
|                       ! ERROR !                                           |
| The test-suite requires that proc_open() is available.         |
| Please check if you disabled it in php.ini.                       |
+--------------------------------------------------------------+


先备份php.ini文件,再修改php.ini文件,将disable列表中的proc_open功能删除

再执行make test
[root@x-phpFAQ-01 imap]# make test

Build complete.
Don't forget to run 'make test'.

PHP Warning:  putenv(): Safe Mode warning: Cannot set environment variable 'SSH_CLIENT' - it's not in the allowed list in /root/lnmp1.0-full/php-5.3.17/ext/imap/run-tests.php on line 98
PHP Warning:  putenv(): Safe Mode warning: Cannot set environment variable 'SSH_AUTH_SOCK' - it's not in the allowed list in /root/lnmp1.0-full/php-5.3.17/ext/imap/run-tests.php on line 99
PHP Warning:  putenv(): Safe Mode warning: Cannot set environment variable 'SSH_TTY' - it's not in the allowed list in /root/lnmp1.0-full/php-5.3.17/ext/imap/run-tests.php on line 100
PHP Warning:  putenv(): Safe Mode warning: Cannot set environment variable 'SSH_CONNECTION' - it's not in the allowed list in /root/lnmp1.0-full/php-5.3.17/ext/imap/run-tests.php on line 101
PHP Warning:  set_time_limit(): Cannot set time limit in safe mode in /root/lnmp1.0-full/php-5.3.17/ext/imap/run-tests.php on line 104

+-----------------------------------------------------------+
|                       ! WARNING !                         |
| You are running the test-suite with "safe_mode" ENABLED ! |
|                                                           |
| Chances are high that no test will work at all,           |
| depending on how you configured "safe_mode" !             |
+-----------------------------------------------------------+

ERROR: invalid PHP executable specified by TEST_PHP_EXECUTABLE  = /usr/local/php/bin/php
作者: urldnscn    时间: 2014-12-12 22:14

这个很受用
作者: tlijian1989    时间: 2016-8-17 10:52     标题: php安装目录在哪呀??

我想装一个redis和mongodb的拓展,我在ext里面没看到

[ 本帖最后由 tlijian1989 于 2016-8-17 11:17 编辑 ]




欢迎光临 VPS侦探论坛 (http://bbs.vpser.net/) Powered by Discuz! 6.0.0