usr bin php config,/usr/local/php/bin/phpize 一个错误(Cannot find config.m4.)解决办法

本文详细介绍了如何在Linux环境中创建并安装一个自定义的PHP扩展。从使用`ext_skel`生成扩展的基本结构,到修改`config.m4`和源代码文件,再到执行`phpize`、`configure`、`make`和`make install`等命令,最终成功将扩展集成到PHP中。通过这个过程,读者可以理解PHP扩展的构建流程。
摘要由CSDN通过智能技术生成

# /usr/local/php/bin/phpizeCannot find config.m4.Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module修改方法:[root@centos lnmp]# cd php-5.2.14ext/[root@centos ext]# ./ext_skel --extname=my_moduleCreating directory my_moduleCreating basic files: config.m4 config.w32 .cvsignore my_module.c php_my_module.h CREDITS EXPERIMENTAL tests/001.phpt my_module.php [done].To use your new extension, you will have to execute the following steps:1. $ cd ..2. $ vi ext/my_module/config.m43. $ ./buildconf4. $ ./configure --[with|enable]-my_module5. $ make6. $ ./php -f ext/my_module/my_module.php7. $ vi ext/my_module/my_module.c8. $ makeRepeat steps 3-6 until you are satisfied with ext/my_module/config.m4 andstep 6 confirms that your module is compiled into PHP. Then, start writingcode and repeat the last two steps as often as necessary.[root@centos ext]# cd my_module/[root@centos my_module]# vim config.m4根据你自己的选择将dnl PHP_ARG_WITH(my_module, for my_module support,dnl Make sure that the comment is aligned:dnl [ --with-my_module Include my_module support])修改成PHP_ARG_WITH(my_module, for my_module support,Make sure that the comment is aligned:[ --with-my_module Include my_module support])或者将dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,dnl Make sure that the comment is aligned:dnl [ --enable-my_module Enable my_module support])修改成PHP_ARG_ENABLE(my_module, whether to enable my_module support,Make sure that the comment is aligned:[ --enable-my_module Enable my_module support])[root@centos my_module]# vim my_module.c将文件其中的下列代码进行修改/* Every user visible function must have an entry in my_module_functions[].*/function_entry my_module_functions[] = {PHP_FE(say_hello,    NULL) /* ?添加着一行代码 */PHP_FE(confirm_my_module_compiled,   NULL) /* For testing, remove later. */{NULL, NULL, NULL}   /* Must be the last line in my_module_functions[] */};在文件的最后添加下列代码PHP_FUNCTION(say_hello){zend_printf("hello sdomain!");}再修改:php_sdomain.hvi php_sdomain.h在PHP_FUNCTION(confirm_my_module_compiled ); /* For testing, remove later. */ 这行的下面添加一行:PHP_FUNCTION(say_hello); /* For testing, remove later. */保存文件退出然后我们就可以在这个目录下使用上面的命令了/usr/local/php/bin/phpize执行以后会看到下面的[root@ns sdomain]# /usr/local/php/bin/phpizeConfiguring for:PHP Api Version:     20020918Zend Module Api No:   20020429Zend Extension Api No:  20050606[root@ns sdomain]#然后执行./configure --with-php-config=/usr/local/php/bin/php-config然后执行makemake install然后他会把对应的so文件生成放到PHP安装目录下面的一个文件夹,并提示在在什么地方,然后再把里面的SO文件拷到你存放SO文件的地方即你在php.ini里面的extension_dir所指定的位置最后一步是你在php.ini文件中打开这个扩展extension=sdomain.so然后重新起动apache

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值