Build PHP extensions using Phpize (Cannot find config.m4)

Source: Internet
Author: User
Tags sapi save file


PHP Source:/root//php-5.5.31
PHP Installation:/usr/local/php


[Email protected] root]# phpize
Cannot find CONFIG.M4.
Make sure this you run '/usr/local/php/bin/phpize ' in the top level source directory of the module

[Email protected] root]# phpize
Cannot find CONFIG.M4.
Make sure this you run '/usr/local/php/bin/phpize ' in the top level source directory of the module


Find this tool under the/usr/local/src/php-4.3.5/ext.
To build a framework for a PHP extension
[[Email protected] ext] #cd/root/soft/php-5.3.4/ext/
[Email protected] ext]#/ext_skel--extname=my_module
Creating Directory My_module
Creating basic files:config.m4. Cvsignore my_module.c php_my_module.h CREDITS experimental TESTS/001.PHPT my_module.php [Done].

To use your new extension and you'll have to execute the following steps:

1. $ CD.
2. $ VI EXT/MY_MODULE/CONFIG.M4
3. $./buildconf
4. $./configure--[with|enable]-my_module
5. $ make
6. $./php-f ext/my_module/my_module.php
7. $ VI ext/my_module/my_module.c
8. $ make
After performing this step, you will see the result.
Repeat steps 3-6 until you is satisfied with EXT/MY_MODULE/CONFIG.M4 and
Step 6 confirms that your module is compiled into PHP. Then, start writing
Code and repeat the last steps as often as necessary.
In this way we will generate a directory under this directory called My_module
Get in here, let's see.
[Email protected] ext]# CD my_module/
[[email protected] my_module]# ls
CONFIG.M4 Experimental my_module.php tests
CREDITS my_module.c php_my_module.h

And then we're going to modify the file order Yes
Configue.m4
My_module.c
Php_my_module.h

Use a text editor to open the Config.m4 file with the following file contents:
DNL $Id $d
DNL config.m4 for extension my_module
DNL don ' t forget to call Php_extension (My_module)
DNL Comments in this file start with the string ' DNL '.
DNL Remove where necessary. This file won't work
DNL without editing.
DNL If your extension references something external, use with:
DNL Php_arg_with (My_module, for my_module support,

DNL Make sure, the comment is aligned:
DNL [--with-my_module Include my_module support])

DNL Otherwise Use enable:
DNL php_arg_enable (My_module, whether to ENABLE my_module support,

DNL Make sure, the comment is aligned:
DNL [--enable-my_module enable my_module support])

if test "$PHP _my_module"! = "no"; Then
DNL If You are not being testing anything external, like existence of

DNL headers, libraries or functions in them, just uncomment the

Dnl following line and your is ready to go.
DNL Write More examples of tests ...
Php_extension (My_module, $ext _shared)

Fi
Depending on your own choice, you will
DNL Php_arg_with (My_module, for my_module support,

DNL Make sure, the comment is aligned:
DNL [--with-my_module Include my_module support])

Modified into
Php_arg_with (My_module, for my_module support,

Make sure, the comment is aligned:
[--with-my_module Include my_module support])

or the
DNL php_arg_enable (My_module, whether to ENABLE my_module support,

DNL Make sure, the comment is aligned:
DNL [--enable-my_module enable my_module support])

Modified into
Php_arg_enable (My_module, whether to ENABLE my_module support,

Make sure, the comment is aligned:

[--enable-my_module enable my_module support])
I used the latter here.
And then save the exit
And then in the edit
Vi my_module.c
Modify the following code in the file

/* Every user visible function must a entry in my_module_functions[].

*/
Function_entry my_module_functions[] = {
Php_fe (Say_hello, NULL)/*? Add a line of code */

Php_fe (confirm_my_module_compiled, NULL)/* For testing, remove later. */

{null, NULL, NULL}/* must is the last line in my_module_functions[] */

};
Add the following code at the end of the file
Php_function (Say_hello)
{
zend_printf ("Hello world/n");

}
Save File Exit
And then we can use the above command in this directory.
/usr/local/php/bin/phpize
You will see the following after execution
[Email protected] my_module]#/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20020918
Zend Module Api no:20020429
Zend Extension Api no:20050606
[Email protected] my_module]#
Then execute./configure--enable-my_module--with-apxs=/usr/local/apache/bin/apxs--with-php-config=/usr/local/php/bin/ Php-config
We can find this file in the bin directory of the PHP after installation
Php-config and Phpize
This step must be aware of where your Apache APXS is placed.
Then execute make
You'll see that there's been an error you redefined the function of our previous
You're going to have to change this file. Delete the original function in the generated file will have the same function
You're adding your code.
It's going to pass.
At this point, a directory will be generated in the current directory called modules.
my_module.so file
CP modules/my_module.so/usr/local/php/ext/
Here you need to set up your PHP extension directory before the
Inside the php.ini.
by Extension_dir
The last one is not you open this extension in the php.ini file
Extension=my_module.so
And then
Re-starting Apache
Use Phpinfo to check the OK.



The specific operation code is as follows:

[Email protected] bin]# cd/root/
[[email protected] ~]# ls
Anaconda-ks.cfg Music
atomic-php55-php-cli-5.5.31-31.el6.art.x86_64.rpm nginx-1.8.0
atomic-php55-php-common-5.5.31-31.el6.art.x86_64.rpm nginx-1.8.0.tar.gz
atomic-php55-php-devel-5.5.31-31.el6.art.x86_64.rpm php-5.5.31
Desktop php-5.5.31.tar.bz2
Documents Pictures
Downloads Public
Eaccelerator-master rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Install.log Templates
Install.log.syslog Videos
Master.zip
[Email protected] ~]# CD php-5.5.31
[[email protected] php-5.5.31]# ls
ACINCLUDE.M4 INSTALL Php5.spec README. TESTING2
ACLOCAL.M4 install-sh php5.spec.in README. Unix-build-system
Build Libs php.gif README. Win32-build-system
buildconf Libtool php.ini-development run-tests.php
Buildconf.bat LICENSE php.ini-production SAPI
Coding_standards ltmain.sh README. EXTENSIONS scripts
Config.guess main README. Ext_skel server-tests-config.php
Config.log makedist README. Git-rules server-tests.php
Config.nice Makefile Readme.input_filter Snapshot
Config.status Makefile.frag README. Mailinglist_rules stamp-h.in
Config.sub makefile.fragments readme.md STUB.C
Configure Makefile.gcov Readme.namespaces Svnclean.bat
Configure.in Makefile.global README. NEW-OUTPUT-API Tests
CREDITS makefile.objects README. PARAMETER_PARSING_API Travis
Ext makerpm README. Php4-to-php5-thin-changes TSRM
EXTENSIONS missing README. REDIST. BINS Upgrading
Footer Mkinstalldirs README. Release_process upgrading. Internals
Generated_lists modules README. Self-contained-extensions Vcsclean
Genfiles NetWare README. STREAMS Win32
Header NEWS README. Submitting_patch Zend
Include Pear README. Testing
[Email protected] php-5.5.31]# CD ext/
[Email protected] ext]#/ext_skel--extname=my_module
Creating Directory My_module
Creating basic files:config.m4 config.w32. Svnignore my_module.c php_my_module.h CREDITS Experimental tes
Ts/001.phpt my_module.php [done].
To use your new extension and you'll have to execute the following steps:

1. $ CD.
2. $ VI EXT/MY_MODULE/CONFIG.M4
3. $./buildconf
4. $./configure--[with|enable]-my_module
5. $ make
6. $./sapi/cli/php-f ext/my_module/my_module.php
7. $ VI ext/my_module/my_module.c
8. $ make

Repeat steps 3-6 until you is satisfied with EXT/MY_MODULE/CONFIG.M4 and
Step 6 confirms that your module is compiled into PHP. Then, start writing
Code and repeat the last steps as often as necessary.

[Email protected] ext]# CD my_module/
[[email protected] my_module]# ls
CONFIG.M4 config.w32 CREDITS Experimental my_module.c my_module.php php_my_module.h tests
[Email protected] my_module]# VI config.m4
[email protected] my_module]# CP config.m4 Config.m4.bak
[Email protected] my_module]# VI config.m4
[email protected] my_module]# CP my_module.c My_module.c.bak
[Email protected] my_module]# VI my_module.c
[Email protected] my_module]#/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20121113
Zend Module Api no:20121212
Zend Extension Api no:220121212
[Email protected] my_module]#

Build PHP extensions using Phpize (Cannot find config.m4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.