如果我们运行php时发现缺少某个库,在windows环境下很简单,找到.dll 对应的库文件,然后拷贝到 extension 目录下,然后在php.ini 里 去掉 前面的分号或者 追加一行 extension = XXXX.dll 即可。

linux环境下,可不是像windows环境下那么的简单。

下面我们已 sysvmsg 这个库文件的安装为例 来详细说明php的编译方法

收件进入php的原始文件

比如我是下载在这个路径下:

[root@localhost php-5.2.17]# cd /root/lnmp0.9-full/php-5.2.17

然后进入 ext 目录

/root/lnmp0.9-full/php-5.2.17/ext

接下来要进入我们需要增加的扩展的包 比如 这里是 sysvmsg

[root@localhost ext]# cd sysvmsg/

接下来我们需要在 sysvmsg 这个目录下创建 configure文件

[root@localhost sysvmsg]# /usr/local/php/bin/phpize  (这里是我们php默认的已经安装的地址)

执行之后会提示以下信息:

[root@localhost sysvmsg]# /usr/local/php/bin/phpize 
Configuring for: 
PHP Api Version:         20041225 
Zend Module Api No:      20060613 
Zend Extension Api No:   220060519

此时我们可以看到 目录下会多出来很多文件

[root@localhost sysvmsg]# ll 
total 1228 
-rw-r--r-- 1 root root  75494 Feb 25 17:30 acinclude.m4 
-rw-r--r-- 1 root root 305818 Feb 25 17:30 aclocal.m4 
drwxr-xr-x 2 root root   4096 Feb 25 17:30 autom4te.cache 
drwxr-xr-x 2 root root   4096 Feb 25 17:30 build 
-rwxr-xr-x 1 root root  44892 Feb 25 17:30 config.guess 
-rw-r--r-- 1 root root   1563 Feb 25 17:30 config.h.in 
-rw-r--r-- 1 1002 1002    425 Aug 24  2006 config.m4 
-rwxr-xr-x 1 root root  33387 Feb 25 17:30 config.sub 
-rwxr-xr-x 1 root root 432846 Feb 25 17:30 configure 
-rw-r--r-- 1 root root   4915 Feb 25 17:30 configure.in 
-rw-r--r-- 1 1002 1002     39 Apr 26  2002 CREDITS 
-rw-r--r-- 1 root root      0 Feb 25 17:30 install-sh 
-rw-r--r-- 1 root root 199728 Feb 25 17:30 ltmain.sh 
-rw-r--r-- 1 root root   5306 Feb 25 17:30 Makefile.global 
-rw-r--r-- 1 root root      0 Feb 25 17:30 missing 
-rw-r--r-- 1 root root      0 Feb 25 17:30 mkinstalldirs 
-rw-r--r-- 1 1002 1002   1012 Jul 15  2009 package.xml 
-rw-r--r-- 1 1002 1002   2045 Jan  3  2010 php_sysvmsg.h 
-rw-r--r-- 1 root root  68898 Feb 25 17:30 run-tests.php 
-rw-r--r-- 1 1002 1002  12642 Jan  3  2010 sysvmsg.c 
drwxr-xr-x 2 1002 1002   4096 Jan  7  2011 tests 
[root@localhost sysvmsg]# pwd 
/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg

再接下去我们就要开始配置新增的内容的,用如下命令

[root@localhost sysvmsg]# ./configure --with-php-config=/usr/local/php/bin/php-config --with--enable-sysvmsg 
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/inclu                                                                                        de/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-deb                                                                                        ug-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 whether to enable System V IPC support... yes, shared 
checking for ANSI C header files... yes 
checking for sys/types.h... yes 
checking for sys/stat.h... yes 
checking for stdlib.h... yes 
checking for string.h... yes 
checking for memory.h... yes 
checking for strings.h... yes 
checking for inttypes.h... yes 
checking for stdint.h... yes 
checking for unistd.h... yes 
checking sys/msg.h usability... yes 
checking sys/msg.h presence... yes 
checking for sys/msg.h... yes 
checking for ld used by cc... /usr/bin/ld 
checking if the linker (/usr/bin/ld) is GNU ld... yes 
checking for /usr/bin/ld option to reload object files... -r 
checking for BSD-compatible nm... /usr/bin/nm -B 
checking whether ln -s works... yes 
checking how to recognize dependent libraries... pass_all 
checking dlfcn.h usability... yes 
checking dlfcn.h presence... yes 
checking for dlfcn.h... yes 
checking the maximum length of command line arguments... 98304 
checking command to parse /usr/bin/nm -B output from cc object... ok 
checking for objdir... .libs 
checking for ar... ar 
checking for ranlib... ranlib 
checking for strip... strip 
checking if cc supports -fno-rtti -fno-exceptions... no 
checking for cc option to produce PIC... -fPIC 
checking if cc PIC flag -fPIC works... yes 
checking if cc static flag -static works... yes 
checking if cc supports -c -o file.o... yes 
checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes 
checking whether -lc should be explicitly linked in... no 
checking dynamic linker characteristics... GNU/Linux ld.so 
checking how to hardcode library paths into programs... immediate 
checking whether stripping libraries is possible... yes 
checking if libtool supports shared libraries... yes 
checking whether to build shared libraries... yes 
checking whether to build static libraries... no

creating libtool 
appending configuration tag "CXX" to libtool 
configure: creating ./config.status 
config.status: creating config.h 
[root@localhost sysvmsg]# make 
/bin/sh /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/libtool --mode=compile cc  -I.                                                                                         -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg -DPHP_ATOM_INC -I/root/lnmp0.9-full                                                                                        /php-5.2.17/ext/sysvmsg/include -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/main                                                                                         -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg -I/usr/local/php/include/php -I/usr                                                                                        /local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/i                                                                                        nclude/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ex                                                                                        t/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/lnmp0.9-full/php-5.2.17/ext/sysvm                                                                                        sg/sysvmsg.c -o sysvmsg.lo 
mkdir .libs 
 cc -I. -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg -DPHP_ATOM_INC -I/root/lnmp0                                                                                        .9-full/php-5.2.17/ext/sysvmsg/include -I/root/lnmp0.9-full/php-5.2.17/ext/sysvm                                                                                        sg/main -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg -I/usr/local/php/include/php                                                                                         -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/loca                                                                                        l/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include                                                                                        /php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/lnmp0.9-full/php-5.2.17/ext/sy                                                                                        svmsg/sysvmsg.c  -fPIC -DPIC -o .libs/sysvmsg.o 
/bin/sh /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/libtool --mode=link cc -DPHP_A                                                                                        TOM_INC -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/include -I/root/lnmp0.9-full                                                                                        /php-5.2.17/ext/sysvmsg/main -I/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg -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  -DHAVE_CONFIG_H  -g -O2   -o sysvmsg.la                                                                                         -export-dynamic -avoid-version -prefer-pic -module -rpath /root/lnmp0.9-full/php                                                                                        -5.2.17/ext/sysvmsg/modules  sysvmsg.lo 
cc -shared  .libs/sysvmsg.o   -Wl,-soname -Wl,sysvmsg.so -o .libs/sysvmsg.so 
creating sysvmsg.la 
(cd .libs && rm -f sysvmsg.la && ln -s ../sysvmsg.la sysvmsg.la) 
/bin/sh /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/libtool --mode=install cp ./sy                                                                                        svmsg.la /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/modules 
cp ./.libs/sysvmsg.so /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/modules/sysvmsg.                                                                                        so 
cp ./.libs/sysvmsg.lai /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/modules/sysvmsg                                                                                        .la 
PATH="$PATH:/sbin" ldconfig -n /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/modules 
---------------------------------------------------------------------- 
Libraries have been installed in: 
   /root/lnmp0.9-full/php-5.2.17/ext/sysvmsg/modules

If you ever happen to want to link against installed libraries 
in a given directory, LIBDIR, you must either use libtool, and 
specify the full pathname of the library, or use the `-LLIBDIR' 
flag during linking and do at least one of the following: 
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable 
     during execution 
   - add LIBDIR to the `LD_RUN_PATH' environment variable 
     during linking 
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag 
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for 
more information, such as the ld(1) and ld.so(8) manual pages. 
----------------------------------------------------------------------

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

[root@localhost sysvmsg]# make install 
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non                                                                                        -zts-20060613/

到这里我们就是安装完成了,会在extentsion目录下创建需要用到得.so 库文件

[root@localhost no-debug-non-zts-20060613]# ll 
total 504 
-rwxr-xr-x 1 root root 340289 Feb 22 19:02 memcache.so 
-rwxr-xr-x 1 root root 121553 Feb 22 19:02 pdo_mysql.so 
-rwxr-xr-x 1 root root  36914 Feb 25 17:33 sysvmsg.so 
[root@localhost no-debug-non-zts-20060613]# cd /usr/local/php/etc/ 
[root@localhost etc]# ll 
total 64 
-rw-r--r-- 1 root root  5712 Feb 22 19:02 php-fpm.conf 
-rw-r--r-- 1 root root  5194 Feb 22 19:01 php-fpm.conf.default 
-rw-r--r-- 1 root root 45469 Feb 25 17:26 php.ini

然后我们需要修改php.ini 新增 .so 库文件

extension = "sysvmsg.so"

用wq 保存php.ini.

最后别忘了重新启动php

[root@localhost etc]# ps -ef | grep php 
root     11702     1  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
www      11703 11702  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
www      11704 11702  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
www      11705 11702  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
www      11706 11702  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
www      11707 11702  0 17:20 ?        00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf 
root     15214 10781  0 17:34 pts/4    00:00:00 grep php 
root     28908 28907  0 13:25 pts/1    00:00:00 /usr/local/php/bin/php /opt/nowtel/sh/MemDaemon.php 
[root@localhost etc]# killall -9 /usr/local/php/bin/php-cgi 
[root@localhost etc]# /usr/local/php/sbin/php-fpm start 
Starting php_fpm  done

好了,这样我们就完成了一个新的模块的安装。

linux下编译php追加enable的方法的更多相关文章

  1. <iostream> 和 <iostream.h>的区别 及 Linux下编译iostream.h的方法

    0.序言 其实2者主要的区别就是iostream是C++标准的输入输出流头文件,而iostream.h是非标准的头文件. 标准头文件iostream中的函数属于标准命令空间,而iostream.h中的 ...

  2. linux安装软件的几种方法----linux下编译安装软件的一般步骤

    linux安装软件的几种方法: 一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd so ...

  3. Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式CentOS7-1810下实现

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  4. Linux下搭建iSCSI共享存储的方法 Linux-IO Target 方式 Debian9.5下实现

    iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速 ...

  5. LINUX下编译安装PHP各种报错大集合

    本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. nginx1.6.2-mysql5.5.32二进制,php安装报错解决: 123456 [root@clien ...

  6. 如何用javac 和java 编译运行整个Java工程 (转载)【转】在Linux下编译与执行Java程序

    如何用javac 和java 编译运行整个Java工程 (转载)  http://blog.csdn.net/huagong_adu/article/details/6929817 [转]在Linux ...

  7. 【原创】Linux下编译链接中常见问题总结

    前言 一直以来对Linux下编译链接产生的问题没有好好重视起来,出现问题就度娘一下,很多时候的确是在搜索帮助下解决了BUG,但由于对原因不求甚解,没有细细研究,结果总是在遇到在BUG时弄得手忙脚乱得. ...

  8. Linux 下编译、安装、配置 QT

    转自Linux 下编译.安装.配置 QT 注意:编译安装耗时费力,且很容易出错,要不断调整编译参数,不推荐使用,否则这将会是一个纠结痛苦的过程. 打算做嵌入式图像处理,计划方案嵌入式Linux+Ope ...

  9. linux下编译eXosip、osip,以及UAC和UAS的例子

    从网站上看到了这样的一篇博文 :Windows下编译eXosip.osip,以及UAC和UAS的例子 (链接:http://www.cnblogs.com/dyllove98/archive/2013 ...

随机推荐

  1. Sharepoint 2013 左右&quot;SPChange&quot;一个简短的引论

    于SharePoint于,我们经常需要获得这些更改项目,竟api为我们提供SPChange物.下列,在通过我们的目录资料这一目标. 1.创建测试列表,名字叫做"SPChangeItems&q ...

  2. CodeForces 425E Sereja and Sets

    意甲冠军: 集S它包括了很多间隔[l,r]  和1<=l<=r<=n  f(S)个不相交的区间  问给出n和f(S)  有几种可能的S集合 思路: dp好题  至于为啥是dp-  我 ...

  3. JS 精度问题处理

    /除法函数,用来得到精确的除法结果 //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显.这个函数返回较为精确的除法结果. //调用:accDiv(arg1,arg2) ...

  4. Java设计模式之装饰者模式

    要实现装饰者模式,注意一下几点内容: 1.装饰者类要实现真实类同样的接口 2.装饰者类内有一个真实对象的引用(可以通过装饰者类的构造器传入) 3.装饰类对象在主类中接受请求,将请求发送给真实的对象(相 ...

  5. Win7搭建NodeJs开发环境

    Win7搭建NodeJs开发环境以及HelloWorld展示—图解 Windows 7系统下搭建NodeJs开发环境(NodeJs+WebStrom)以及Hello World!展示,大体思路如下:第 ...

  6. unpivot,pivot,case when ,行转列,列转行 sql server

    http://technet.microsoft.com/zh-cn/library/ms177410.aspx unpivot : CREATE TABLE pvt (VendorID int, E ...

  7. 走进windows编程的世界-----windows进程

    Windows进程  1 Windows进程    进程是一个容器,包括了一个应用程序实例的各种资源.Windows多任务的操作系统,因此能够同一时候运行多个进程.      2 Windows进程的 ...

  8. javascript常用知识点集

    javascript常用知识点集 目录结构 一.jquery源码中常见知识点 二.javascript中原型链常见的知识点 三.常用的方法集知识点 一.jquery源码中常见的知识点 1.string ...

  9. php中utf8 与utf-8

    原文:php中utf8 与utf-8 相信很多程序员刚开始也会有这样的疑惑,如题,我也是.    其实,他们可以这样来区分.    一.在php和html中设置编码,请尽量统一写成“UTF-8”,这才 ...

  10. C语言第12轮:指针

    C语言第12轮:指针 [学习目标] 1.        指针 2.        指针与数组 A: 指针的概念 内存存储单元按字节排序.每一个字节编有序号.我们称之为地址.因为能够通过地址就能够找到所 ...