|
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
主站蜘蛛池模板:
天等县|
嘉义市|
绥芬河市|
石棉县|
大宁县|
合作市|
东港市|
东方市|
静宁县|
龙门县|
兴宁市|
台南市|
舟曲县|
宝鸡市|
东乡族自治县|
内黄县|
凉城县|
金沙县|
阜康市|
海林市|
维西|
拉萨市|
双城市|
汽车|
岚皋县|
丹江口市|
昌邑市|
张家港市|
克什克腾旗|
奉化市|
德格县|
禹州市|
焉耆|
克东县|
福建省|
探索|
营口市|
平凉市|
高安市|
云南省|
铜鼓县|