phpize建立php擴展 Cannot find config.m4


phpize建立php擴展Cannot find config.m4
[root@ns root]# phpize
  Cannot find config.m4.
   Make sure that you run /usr/local/bin/phpize in the top level source directory of the module

出現這個無法安裝PHP的拓展的

在/usr/local/src/php-5.6.31/ext下找到這個工具
  來建立一個php擴展的一個框架
  [root@ns ext]#cd /usr/local/src/php-5.6.31/ext/
  [root@ns ext]# ./ext_skel --extname=sdomain
To use your new extension, you will have to execute the following steps:
  1. $ cd ..
  2. $ vi ext/sdomain/config.m4
  3. $ ./buildconf
  4. $ ./configure --[with|enable]-sdomain
  5. $ make
  6. $ ./php -f ext/sdomain/sdomain.php
  7. $ vi ext/sdomain/sdomain.c
  8. $ make
[root@ns ext]# cd sdomain/
  [root@ns sdomain]# ls
  config.m4 EXPERIMENTAL     sdomain.php  tests
  CREDITS  sdomain.c php_sdomain.h
  然后我們要修改文件順序是
  configue.m4
  sdomain.c
  php_sdomain.h
使用文本編輯器打開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,
  [ --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,
  [ --enable-my_module      Enable my_module support])
(其實就是將這部分的dnl去掉,在這個文件里dnl就是注釋的意思,相當於我們PHP里面的#或// 另外把他中間的一句描術也去掉)
然后保存退出
  然后在編輯
  Vi 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 my_module!");
}

再修改:php_my_module.h
vi php_my_module.h


PHP_FUNCTION(confirm_my_module_compiled); 這行的下面添加一行:

PHP_FUNCTION(say_hello); /* For testing, remove later. */
保存文件退出

進行安裝

cd /usr/local/src/php-5.6.31/

./configure --prefix=/usr/local/php --with-libxml-dir=/usr/local/libxml --with-apxs2=/usr/local/apache/bin/apxs

make && make install

安裝完后,居然沒有ext拓展,只能復制源碼包里的過來了

cp -r /usr/local/src/php-5.6.31/ext /usr/local/php/

然后我們就可以在這個目錄下使用上面的命令了
/usr/local/php/bin/phpize

如果正常就顯示這個

Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226

如果沒出現這2句就還好,如果出現這2句,則需要 yum -y install m4 autoconf
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

 

如果失敗還是顯示

Cannot find config.m4

源碼包安裝后,沒有php.ini的話可以直接復制

cp /usr/local/src/php-5.6.31/php.ini-production /usr/local/php5/lib/php.ini

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM