1. 下載PHP並解包
tar zxvf PHP-5.2.8.tar.gz
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d PHP-5.2.8 -p1
cd php-5.2.8/ 2. 使用PHP工具生成基本的擴展模塊的架構
./ext_skel --extname myext
cd myext 3. 修改config.m4 PHP_ARG_WITH(myext, for myext support,
dnl Make sure that the comment is aligned:
[ --with-myext Include myext support]) PHP_ARG_ENABLE(myext, whether to enable myext support,
dnl Make sure that the comment is aligned:
[ --enable-myext Enable myext support]) 4. 在當前目錄使用PHPize生成配置文件 5. 生成擴展庫
./configure --with-myext --with-PHP-config=PATH
make
make install 6. 修改php.ini,增加擴展myext.so 7.重啟PHP-CGI 8. 運行測試腳本
<?PHP
print confirm_myfunctions_compiled("myextension");
?>