phpize学习

简介: Compiling shared PECL extensions with phpizeSometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or i...

Compiling shared PECL extensions with phpize

Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from SVN. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.

The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:

$ cd extname  进入到源码包中的扩展目录,这个扩展目录,通俗理解,如果要安装操作gd库,那么下载到这个库的源码后,解压源码会有个一个目录,进入这个目录。
$ phpize  运行phpize。路径不一定在这个目录下,但一般是在安装目录下(按照我理解,每个phpize与具体的版本有关,不可能通用),去寻找phpize运行。之后会生成了一个configure文件
$ ./configure     运行。    如果生成基于数据库的扩展,需要加上参数运行:1,--with-php-config。2,"--with-具体的数据库参数".比如, --with-pgsql、--with-mysql
$ make
# make install 将会生成一个extname.so的扩展,被放到了PHP extensions directory

 


A successful install will have created extname.so and put it into the PHP extensions directory(生成一个.so文件,自动放到php的扩展目录下去,我觉得应该是phpize能够自动侦测到php扩展目录的位置).

You'll need to and adjust php.ini and add an extension=extname.so line before you can use the extension.

If the system is missing the phpize command, and precompiled packages (like RPM's) are used, be sure to also install the appropriate devel version of the PHP package as they often include the phpize command along with the appropriate header files to build PHP and its extensions.

Execute phpize --help to display additional usage information.


phpize的作用可以这样理解:侦测环境(phpize工具是在php安装目录下,基于这点phpize对应了当时的php环境,所以是要根据该php的配置情况生成对应的configure文件),建立一个configure文件。必须在一个目录下去运行phpize。那么phpize就知道你的的环境是哪个目录,并且configure文件建立在该目录下。

步骤总结:

一、cd /usr/src/php源码包目录/ext/扩展目录/ 

二、/usr/local/php5314/bin/phpize


三、./configure --with-php-config=/usr/local/php5314/bin/php-config

四、make && make install

 

ps:make install会自动将生成的.so扩展复制到php的扩展目录下去,比如会提示已经安装到 /usr/local/php/php-5.5.18/lib/php/extensions/no-debug-non-zts-20121212/目录下去
五、剩下是配置php.ini

 




假如你的服务器上安装了多个版本php,那么需要告诉phpize要建立基于哪个版本的扩展。通过使用--with-php-config=指定你使用哪个php版本。

比如:--with-php-config=/usr/local/php524/bin/php-config 

关于php-config文件:是在php编译生成后(安装好),放在安装目录下的一个文件。打开phpize文件内容会发现,里面定义好了php的安装目录等变量

prefix='/usr/local/php'

phpize是编译安装时候生成好的,记录了当时安装的一些信息。并不能从其他地方拿个phpize来使用。

 phpize是在php安装目录下的一个文件。比如我安装了两个php5.2 和php5.3那么使用phpize也要使用对应版本的phpize才行。此时使用--with-php-config有什么作用?

 

phpize工具一般在哪里?

当php编译完成后,php安装目录下的bin目录下会有phpize这个脚本文件。所以是去安装好的php安装目录去找。

 

目录
相关文章
|
存储 缓存 NoSQL
Redis的5.0/6.0/7.0版本重点介绍以及使用!
1. Stream数据类型:Redis 5.0引入了Stream数据类型,它是一种日志结构,用于高性能、持久化和实时处理的数据流。Stream可以按照时间顺序存储和检索消息,并支持消费者组和消费者偏移量管理等功能。 2. 基于模块的全文搜索:Redis 5.0通过引入Redis Search模块,提供了全文搜索的功能。它支持对文本字段进行索引和搜索,包括分词、词项权重、布尔查询等功能。 3. 客户端缓存:Redis 5.0引入了客户端缓存(Client-side caching)功能。客户端可以缓存服务器返回的数据,减少对服务器的请求,提高性能和响应速度。
4061 1
|
JSON 开发工具 C++
Windows下用CMake编译JsonCpp及配置(适合新手)
Windows下用CMake编译JsonCpp及配置(适合新手)
1373 0
|
负载均衡 虚拟化 数据中心
思科 WLC 部署模型详解
【4月更文挑战第22天】
371 1
思科 WLC 部署模型详解
KyLinV10 安装realtek-r8125 2.5G网卡驱动。
KyLinV10 安装realtek-r8125 2.5G网卡驱动。
|
SQL XML 关系型数据库
【less-5】基于SQLI的SQL盲注常用函数
【less-5】基于SQLI的SQL盲注常用函数
|
存储 算法 Android开发
【算法基础】拓扑排序及实战
在图论中,如果一个有向图从任意顶点出发无法经过若干条边回到该点,则这个图是一个**有向无环图(DAG,Directed Acyclic Graph)**
|
Web App开发 前端开发 Android开发
svg图标无法修改颜色的解决方案
svg图标无法修改颜色的解决方案
|
监控 数据挖掘 BI
ERP系统中的成本管理与生产成本核算解析
【7月更文挑战第25天】 ERP系统中的成本管理与生产成本核算解析
1320 3
|
算法 NoSQL Java
6种限流实现,附代码![通俗易懂]
6种限流实现,附代码![通俗易懂]
1020 0
6种限流实现,附代码![通俗易懂]
|
开发者
ESP8266实战贴:使用HTTP POST请求上传数据到公有云OneNet
ESP8266实战贴:使用HTTP POST请求上传数据到公有云OneNet
1148 0