|
1.首先是要安裝好php
2.進入php的下載解壓目錄下的ext目錄
#cd /root/php-5.3.6/ext
#./ext_skel --extname=hmc
說明:
./ext_skel --extname=module_name
module_name是你自己可以選擇的擴展模塊的名字,例如我選擇的hmc。執行工具后會自動在ext目錄下建立你選擇的module_name名字的目錄,里面已經生成了相關的代碼,這些代碼中只需要調整config.m4文件中的三行注釋就可以正常的編譯帶這個自定義擴展模塊的php了。
3.修改config.m4
可以將生成的module目錄復制到任意希望放置的地方
進入hmc目錄
vi config.m4
使用文本編輯器打開config.m4文件
根據你自己的選擇將
dnl php_ARG_WITH(hmc, for hmc support,
dnl Make sure that the comment is aligned:
dnl [ --with-hmc Include hmc support])
修改成
php_ARG_WITH(hmc for hmc support,
Make sure that the comment is aligned:
[ --with-hmc Include hmc support])
或者將
dnl php_ARG_ENABLE(hmc, whether to enable hmc support,
dnl Make sure that the comment is aligned:
dnl [ --enable-hmc Enable hmc support])
修改成
php_ARG_ENABLE(hmc, whether to enable hmc support,
Make sure that the comment is aligned:
[ --enable-hmc Enable hmc support])
一般我會選擇后者,然后保存退出。
4.修改.c和.h文件代碼
Vi hmc.c
將文件其中的下列代碼進行修改
/* Every user visible function must have an entry in hmc_functions[].
*/
const zend_function_entry hmc_functions[] = {
php_FE(say_hello, NULL) /* 添加著一行代碼 */
php_FE(confirm_hmc_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in hmc_functions[] */
};
在文件的最后添加下列代碼
php_FUNCTION(say_hello)
{
zend_printf("hello world/n");
}
保存文件退出
vi php_hmc.h
在文件中php_FUNCTION(confirm_hmc_compiled);一行前面添加下面的代碼
php_FUNCTION(say_hello);
保存文件退出
5.編譯安裝
#phpize
#./configure --enable-hmc
#make
#make install
應該在php的modules目錄下有一個hmc.so文件,不同的機器位置會不一樣
6.修改php配置
編輯php.ini,把擴展加入進去:
在[php]模塊下增加:
extension = hmc.so
重啟Httpd
#service httpd restart
7.php調用
建立一個c.php文件在對應的www目錄下
<?
say_hello();
?>
這時瀏覽器應該輸出:
hello world
8.調試
可以在命令行下輸入
#php
主站蜘蛛池模板:
黄陵县|
万盛区|
东乡族自治县|
兰溪市|
容城县|
梅河口市|
陇南市|
巴林左旗|
利津县|
江达县|
玛曲县|
治多县|
鹤峰县|
河北省|
昂仁县|
如东县|
深水埗区|
武陟县|
河西区|
天台县|
申扎县|
迁西县|
胶南市|
高台县|
塔河县|
金塔县|
伊宁县|
临漳县|
延寿县|
南开区|
喀喇|
凤山县|
桃园市|
古浪县|
贵港市|
繁峙县|
芦山县|
武安市|
阳山县|
勐海县|
苏州市|