Home > Backend Development > PHP Tutorial > 编译PHP扩展的通用步骤

编译PHP扩展的通用步骤

WBOY
Release: 2016-06-13 12:28:12
Original
886 people have browsed it

编译PHP扩展的通用方法

  以安装swoole扩展为例:

  步骤1: wget  pecl.php.net/get/swoole-1.7.21.tgz  (下载swoole打包文件)

  步骤2: tar zxvf swoole-1.7.21.tgz  (解压swoole压缩文件)

  步骤3: cd  swoole-1.7.21  (进入swoole目录)

  步骤4:   /usr/local/php/bin/phpize  (或直接使用phpizephpize 命令是用来准备 PHP 扩展库的编译环境的,每个人的phpize命令的路径可能不同,不要直接复制执行)

  步骤5:  ./configure  --with-php-config=/usr/local/php/bin/php-config  (或直接使用./configure 。./configure 作用是对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系)

  步骤6: make (编译)

  步骤7: make test (这一步就是对上一步 make 的检查了,要确保 make 是没有错误的)

  步骤8: make install

  执行完make install会看到类似这样的信息:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ ,这条路径就是PHP扩展(extension_dir)的路径,安装成功的swoole.so就在该目录里。

  步骤9:  vim /usr/local/php/lib/php.ini  添加extension=swoole.so

  步骤10: service php-fpm reload(或 service php-fpm restart,重启PHP的FastCGI进程管理器,现在我已经把nginx,php-fpm的服务启动脚本已经写进/etc/rc.d/init.d)

 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template