|
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
主站蜘蛛池模板:
读书|
夏河县|
岱山县|
阿尔山市|
宝丰县|
曲阳县|
大安市|
龙海市|
阜宁县|
漳浦县|
双柏县|
明溪县|
清涧县|
沽源县|
奉贤区|
安阳县|
瑞金市|
高雄市|
托克托县|
临海市|
江华|
盐山县|
乐业县|
吴桥县|
格尔木市|
延庆县|
镇远县|
岳普湖县|
汾阳市|
房山区|
甘南县|
双辽市|
福建省|
邵武市|
凉山|
竹山县|
盈江县|
长岛县|
江城|
杭锦后旗|
恩平市|