|
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
主站蜘蛛池模板:
道真|
卓尼县|
泽普县|
新丰县|
方城县|
青龙|
丹寨县|
西贡区|
大埔区|
宜丰县|
津南区|
丽江市|
临汾市|
钦州市|
洪洞县|
余江县|
宜宾市|
潞城市|
永新县|
贵德县|
勃利县|
田阳县|
措勤县|
册亨县|
错那县|
万州区|
建始县|
察隅县|
靖江市|
宁武县|
金昌市|
内乡县|
濉溪县|
米泉市|
宜黄县|
都匀市|
绵阳市|
金平|
宣化县|
大连市|
商都县|