linux環境下安裝php擴展

本文只提供源碼安裝的方法(已安裝pcntl爲例)php

其餘方法請參考:http://doc3.workerman.net/appendices/install-extension.htmlhtml

一、利用php -v命令查看當前的PHP Cli的版本shell

~# php -v
PHP 5.3.29-1~dotdeb.0 with Suhosin-Patch (cli) (built: Aug 14 2014 19:55:20)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

二、根據版本下載PHP源代碼bash

PHP歷史版本下載頁面:http://php.net/releases/app

三、解壓源碼壓縮包ui

例以下載的壓縮包名稱是php-5.3.29.tar.gz.net

~# tar -zxvf php-5.3.29.tar.gz
php-5.3.29/
php-5.3.29/README.WIN32-BUILD-SYSTEM
php-5.3.29/netware/
...

四、進入源碼中的ext/pcntl目錄code

~# cd php-5.3.29/ext/pcntl/

五、運行 phpize 命令htm

~# phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

六、運行 configure命令get

~# ./configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
...

七、運行 make 命令

~# make
/bin/bash /tmp/php-5.3.29/ext/pcntl/libtool --mode=compile cc ...
-I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend...
...

八、運 行make install 命令

~# make install
Installing shared extensions:     /usr/lib/php5/20090626/

九、配置ini文件

經過運行 php --ini查找php.ini文件位置,而後在文件中添加extension=pcntl.so

說明: 此方法通常用來安裝PHP自帶的擴展,例如posix擴展和pcntl擴展。除了用phpize編譯某個擴展,也能夠從新編譯整個PHP,在編譯時用參數添加擴展,例如在源碼根目錄運行

~# ./configure --enable-pcntl --enable-posix ...
~# make && make install
相關文章
相關標籤/搜索