First step: Install PHP5
The second step: Open the terminal "for the convenience, here using the root user", using the CD command to enter the PHP5 source package ext Directory
Step three: Type the following command at the terminal
./ext_skel--extname=extest
Our extension library is called "Extest", and this command executes and creates a new Extest directory in the EXT directory.
Fourth step: Return to the terminal, use the CD command to enter the Extest directory, type the following command/var/web/php/bin/phpize
This is the webmaster's phpize directory, you need to change into your own. After running, the CONFIG.M4 and Config.w32 (used under Windows) and the Configure program are generated in the Extest directory.
Double click Open extest Directory, open php_extest.h file, find Php_function (confirm_extest_compiled);
Add Php_function (Extest_add) to this line and exit after saving.
Here is the Add function we want to write for the Extest library to the declaration.
Fifth step: Open the Extest.c file, find the const zend_function_entry extest_functions[], look down 3 lines, add Php_fe (Extest_add, NULL) on the top row of Php_fe_end, Add the function implementation to the code at the end of the file:
Click (here) to collapse or open
Php_function (extest_add) {long int a,b,c;if (Zend_parse_parameters (Zend_num_args () tsrmls_cc, "ll", &a,&b) = = FAILURE) {return;} C=a+b; Return_long (c);}
Exit after saving.
Sixth step: Open the Config.m4 file to find
Php_arg_enable (Caleng_module, whether to ENABLE caleng_module ... And
[--enable-caleng_module enable caleng_module support]) Two lines, remove the previous DNL open.
Seventh step: Return to the terminal, use the CD command to enter the Extest directory, type the command:
./configure--with-php-config=/var/web/php/bin/php-config
Make
Make install
/var/web/php/bin/php-config This is the directory of webmaster php-config files, you should modify it to your own.
If the compilation is successful, a extest.so file will be generated in the Extest/moduels directory and the/var/web/php/lib/php/extensions/no-debug-non-zts-20090626 directory.
Eighth step: Open php.ini, add extension=extest.so, save exit.
Nineth Step: If you are using Apache, restart Apache. If you are using NGINX+PHP-FPM, you need to restart PHP-FPM.
How do I restart PHP-FPM? Webmaster did not do restart settings, should this have to kill PHP-FPM process in the restart.
Open/var/web/php/var/log/php-fpm.log, navigate to document Finally, view PHP-FPM to process number, mine is 2156.
Back to the terminal, use the command kill 2156 to kill the PHP-FPM process.
Then restart PHP-FPM, return to the terminal using the CD command to enter the/var/web/php/sbin directory, using the./php-fpm restart PHP-FPM.
Tenth step: Test the Extension library. Create a new index.php file with the following code:
<?php
Echo Extest_add ();
Phpinfo ();
?>
Linux PHP extensions