English | VPS常用软件下载 |
  • 美国VPS主机推荐
  • |
  • 代购服务
  • |
  • 10美元以下VPS
  • |
  • VPS新手指南/教程
  • |
  • 留言板
  • |
  • 关于VPSer
  • | VPS论坛 | 登录 |

    lnmp之安装PHP模块(不需要重装PHP)

    2010年08月16日 下午 | 作者:

    VPS侦探一直在努力的去营造一个VPS相关话题的交流环境,于是有了很多的VPS相关的教程、QQ群、有了论坛、有了LNMP一键安装包...

    VPS侦探主要根据论坛上lnmp版块用户反映来写一些教程,今天说一下如何为lnmp的php安装一些自己需要的模块

    本文以imap和exif模块为例。

    一、安装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 执行这个的时候是会检查系统上库是否安装上,如果没有安装上就会报错,按错误提示安装相关的库就行。

    如果还有其他问题,可以到http://bbs.vpser.net提问,记得提问前在http://bbs.vpser.net/search.php搜索一下哦。

    >>转载请注明出处:VPS侦探 本文链接地址:http://www.vpser.net/manage/lnmp-php-install-ext.html

    相关文章:

    VPS侦探推荐:

    DiaHostingLinodePhotonVPSVPSYou瑞豪开源ECVPS美国VPS主机
    欢迎加入VPS侦探论坛交流:http://bbs.vpser.net

    评论(14 条评论)

    1. 执行"make && make install” 报错 “make: *** No targets specified and no makefile found. Stop.”

      VPSer 回复:

      @祝正江, 前面的一步报错了吧

    2. 我从来就没有改过路径,路径没有错,但就是一直提示找不到php-config, 搞不懂了,可以帮我想想办法不?

    3. 一直提示找不到php-config,难道要重新编译安装php?怎么编译安装?最好可以告诉代码,新手,谢谢

    4. 执行这个./configure --with-php-config=/usr/local/php/bin/php-config命令的时候,提示如下错误

      configure: error: This c-client library is built with Kerberos support.

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

      我就在php-config里的增加了‘--with-kerberos'

      再次执行./configure --with-php-config=/usr/local/php/bin/php-config
      提示错误configure: error: Cannot find php-config. Please use --with-php-config=PATH 找不到php-config这个文件,即使我把php-config改回去,依然提示找不到php-config文件,

      怎么回事?

      VPSer 回复:

      @tt, --with-php-config=PATH PATH换成你的php-config的路径。configure: error: This c-client library is built with Kerberos support. 参见:http://bbs.vpser.net/viewthread.php?tid=1557&page=1&fromuid=3#pid4466

    5. 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... new
      checking for U8T_DECOMPOSE...
      checking for pam_start in -lpam... yes
      checking for crypt in -lcrypt... yes
      configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

      没有安装库?

      VPSer 回复:

      @無名指, 安装imap需要一些其他的依赖包,详细查看http://bbs.vpser.net/viewthread.php?tid=1150

    6. 按此方法安装imap模块没成功.

      装到[root@vpser imap]# ./configure --with-php-config=/usr/local/php/bin/php-config这一步提示如下:

      [root@tedy imap]# ./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... 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... no
      checking for IMAP SSL support... no
      checking for utf8_mime2text signature... old
      checking for U8T_CANONICAL... no
      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.

      好象没有kerberos.

      装到[root@vpser imap]# make && make install提示如下:

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

      请回咋办

      用的是lnmp0.4

      VPSer 回复:

      @teddy,
      configure: error: This c-client library is built with Kerberos support.
      Add --with-kerberos to your configure line. Check config.log for details.这里已经提示错误原因了。
      执行configure哪一步时在编译参数上加上--with-kerberos 再重新编译,不报错了再make

    7. @shiny, 我这边正常,通过webkaka测试的地市也都是正常的。

    8. vpser GFWed?

    9. :D :D

      有没有平滑升级PHP的方法哦,就是不需要重装PHP的升级到5.2.14. :mrgreen: :mrgreen:

      VPSer 回复:

      @vowanson, 无法平滑升级,肯定会中断一小会儿。按照lnmp脚本下载新版的php,重新编译安装,然后重启就可以。

    发表评论

    *必填

    *必填 (不会被公开)

    :D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: