linux下编译php追加enable的方法

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

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

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

收件进入php的原始文件

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

[[email protected] php-5.2.17]# cd
/root/lnmp0.9-full/php-5.2.17

然后进入 ext 目录

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

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

[[email protected] ext]# cd
sysvmsg/

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

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

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

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

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

[[email protected] 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 
[[email protected] sysvmsg]#
pwd 
/root/lnmp0.9-full/php-5.2.17/ext/sysvmsg

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

[[email protected] 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...

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 
[[email protected] 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‘.

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

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

[[email protected] 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 
[[email protected] no-debug-non-zts-20060613]# cd
/usr/local/php/etc/ 
[[email protected] 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

[[email protected] 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 
[[email protected] etc]# killall -9
/usr/local/php/bin/php-cgi 
[[email protected] etc]#
/usr/local/php/sbin/php-fpm start 
Starting php_fpm 
done

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

linux下编译php追加enable的方法,码迷,mamicode.com

时间: 2024-08-02 02:41:12

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

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

iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI分为服务端和客户端,服务端需要安装scsi target用来共享存储设备,客户端需要安装iscsi initiato

linux下编译安装php各种报错大集合

PHP开源脚本语言 PHP(外文名: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,入门门槛较低,易于学习,使用广泛,主要适用于Web开发领域.PHP的文件后缀名为php. 本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. 报错1:make 后报错如下: Generating phar.php /home/oldboy/tools/php-5.3.27

Linux下编译安装qemu和libvirt

目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 2 安装libvirt 2.1 libvirt介绍 2.2 下载libvirt 2.3 编译安装 3 参考资料 KVM虚拟机(英语:Kernel-based Virtual Machine),是一种用于Linux内核中的虚拟化基础设施.KVM目前支援Intel VT及AMD-V的原生虚拟技术.KVM在2007年2月被导入Linux 2.6.20核心中.它也被引入FreeBSD.在Mac OS X中,

在linux下编译openjdk7

最近刚开始看<深入理解JAVA虚拟机>这本书.第一章的实践是自己手动编译openjdk7,但书上的步骤都是基于windows的,于是在网上搜了一下linux下编译openjdk的资料: http://blog.csdn.net/kindazrael/article/details/7266314 http://guoh.org/lifelog/2011/05/compile-openjdk-by-yourself/ 这辆篇文章都说的比较详细.其实,最好的文档是openjdk源码包中的READM

ffmpeg 在linux下编译

2012-06-25 19:36:06|  分类: 默认分类|举报|字号 订阅 1.下载ffmpeg.    wget http://down1.chinaunix.net/distfiles/ffmpeg-0.4.9-p20051120.tar.bz2 我是在这个网址上下载ffmpeg-0.4.9-p20051120.tar.bz2,看网上有人用的是svn下载,但是我的机子中没有svn客户端,然后就在网上搜索,下载了这个版本.如果利用svn可以下载ffmpeg最新的版本. svn checko

LINUX下使用PHP连接MSSQL的方法

目录[-] 如何安装MSSQL.SO 如何安装PDO_LIB.SO 如何安装PDO_ODBC.SO 作者:Roban lee ([email protected]) LINUX下使用PHP连接MSSQL的方法有很多种,根据不同的环境,可以选择不同的方式,大致方法有以下几种: 使用MSSQL.SO扩展 使用PDO_LIB扩展 使用PDO_ODBC扩展 如何安装MSSQL.SO 1. MSSQL.SO 扩展依赖一个外部包,即 freeTDS, FreeTDS 官网: http://www.freet

linux下coredump的产生及调试方法

什么是coredump 通常情况下coredmp包括了程序执行时的内存,寄存器状态,堆栈指针,内存管理信息等.能够理解为把程序工作的当前状态存储成一个文件.很多程序和操作系统出错时会自己主动生成一个core文件. 怎样使用coredump coredump能够用在非常多场合,使用Linux,或者solaris的人可能都有过这样的经历,系统在跑一些压力測试或者系统负载一大的话,系统就hang住了或者干脆system panic.这时唯一能帮助你分析和解决这个问题的就是coredump了. 如今非常

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

从网站上看到了这样的一篇博文 :Windows下编译eXosip.osip,以及UAC和UAS的例子 (链接:http://www.cnblogs.com/dyllove98/archive/2013/06/25/3155427.html) 觉得对学习sip的初学者,包括我,都是很有帮助的.但是那是在window下的编译,我在这里稍微改了一下,让它支持在linux下编译测试运行通过. 我们这里使用库的版本:libosip2-3.6.0.tar,libeXosip2-3.6.0.tar,大家可以自

Linux 下编译安装xCache命令速记

注意要先确保/path-to-php/bin/php-config存在下载链接: http://pan.baidu.com/s/1hqh5pDM #解压xcache源代码tar -zvxf xcache-3.1.0.tar.gz #进入安装目录cd xcache-3.1.0 #安装前执行phpize配置/path-to-php/bin/phpize #安装配置 ./configure --prefix=/path-to-php/lib/php/extensions \--with-php-con