Use phpize to create the Cannotfindconfig extension for php. m4. original address: lxsym. blog.51cto. com1364623293862 let me talk about how to make a php extension. First of all, we need to have a set up php environment. I installed php in usrlocalphp and, of course, configured php through a php configuration. ini path, but use phpize to create the php extension Cannot find config. m4.
Address: http://lxsym.blog.51cto.com/1364623/293862/
Next, let's talk about how to make a php extension.
First, you must have a set up php environment.
I installed php in/usr/local/php. of course
A php path for configuring php. ini, but pay attention to it.
Php extensions installed in this way cannot be implemented
The/usr/local/php/bin directory after php installation
Find the file phpize. we will use it later.
He is a shell script. you can use vi phpize to view his content.
But you should note that this script can not be applied anywhere.
[[Email protected] root] # phpize
Cannot find config. m4.
Make sure that you run/usr/local/bin/phpize in the top level source directory of the module
[[Email protected] root] # phpize
Cannot find config. m4.
Make sure that you run/usr/local/bin/phpize in the top level source directory of the module
You will see these two results. you actually checked the script.
You can easily find out how to handle it.
It's best for you to scale your model.
Put under/usr/local/src/php-4.3.5/ext
You can also run it here/usr/local/php/bin/phpize.
Phpize to execute
We found this tool under/usr/local/src/php-4.3.5/ext
To build a php extension framework.
[[Email protected] ext] # cd/usr/local/src/php-4.3.5/ext/
[[Email protected] ext] #./ext_skel -- extname = sdomain
Creating directory sdomain
Creating basic files: config. m4. cvsignore sdomain. c php_sdomain.h credits experimental tests/001. phpt sdomain. php [done].
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. php
7. $ vi ext/sdomain. c
8. $ make
After performing this step, you will see this result.
Repeat steps 3-6 until you are satisfied with ext/sdomain/config. m4 and
Step 6 confirms that your module is compiled into PHP. Then, start writing
Code and repeat the last two steps as often as necessary.
In this case, a directory named sdomain will be generated under this directory.
Let's take a look.
[[Email protected] ext] # cd sdomain/
[[Email protected] sdomain] # ls
Config. m4 EXPERIMENTAL sdomain. php tests
CREDITS sdomain. c php_sdomain.h
Then we want to modify the file order as follows:
Configue. m4
Sdomain. c
Php_sdomain.h
Open the config. m4 file in the text editor. the file content is roughly as follows:
Dnl $ Id $ d
Dnl config. m4 for extension my_module
Dnl dont forget to call PHP_EXTENSION (my_module)
Dnl Comments in this file start with the string dnl.
Dnl Remove where necessary. This file will not work
Dnl without editing.
Dnl If your extension references something external, use:
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])
Dnl Otherwise use enable:
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])
If test $ PHP_MY_MODULE! = No; then
Dnl If you will not be testing anything external, like existence
Dnl headers, libraries or functions in them, just uncomment
Dnl following line and you are ready to go.
Dnl Write more examples of tests here...
PHP_EXTENSION (my_module, $ ext_shared)
Fi
Choose
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])
Modify
PHP_ARG_WITH (my_module, for my_module support,
[-- With-my_module Include my_module support])
Or set
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])
Modify
PHP_ARG_ENABLE (my_module, whether to enable my_module support,
[-Enable-my_module Enable my_module support])
(In fact, this part of dnl is removed. in this file, dnl is the meaning of the comment, it is equivalent to # or // In PHP, and also removes a sentence in the middle)
I used the latter here
Save and exit
Then edit
Vi my_module.c
Modify the following code in the file.
/* Every user visible function must have an 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 be the last line in my_module_functions [] */
};
Add the following code at the end of the file
PHP_FUNCTION (say_hello)
{
Zend_printf ("hello sdomain! ");
}
Modify php_sdomain.h.
Vi php_sdomain.h
Add a row under the PHP_FUNCTION (confirm_my_module_compiled);/* For testing, remove later. */line:
PHP_FUNCTION (say_hello);/* For testing, remove later .*/
Save the file and exit
Then we can use the above command in this directory.
/Usr/local/php/bin/phpize
After execution, you will see the following
[[Email protected] sdomain] #/usr/local/php/bin/phpize
Processing ING:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
[[Email protected] sdomain] #
Then run./configure -- with-php-config =/usr/local/php/bin/php-config.
Then execute make
Make install
Then he will put the corresponding so file generation in a folder under the PHP installation directory, and prompt where it is, and then copy the SO file to the place where you store the SO file.
That is, the location specified by extension_dir in php. ini.
The last step is to open the extension in the php. ini file.
Extension = sdomain. so
Then
Restart apache
Use phpinfo to check whether it is OK.
This article from The CSDN blog, reproduced please indicate the source: http://blog.csdn.net/sdomain/archive/2009/09/04/4520425.aspx