In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use c to write the php expansion module in ubuntu12.04, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
The system is ubuntu 12.04, and the version of apache and php,php is 5.3.10.
If the following operation encounters permission problems, it is recommended to switch to root operation.
1. Download the source code
Check out the source code for php 5.3.10
The code is as follows:
$svn checkout https://svn.php.net/repository/php/php-src/branches/PHP_5_3_10/
Tips: if you don't have this command, you need to install svn first. Use apt-get to install OK directly under ubuntu:
The code is as follows:
$sudo apt-get install subversion
For more information about the php source code, you can check out the description of svn in the php wiki: https://wiki.php.net/vcs/svnfaq
2. Create a module
A. After the source code is checked out, enter the source code ext directory, and first create a module with ext_skel. The module name is my:
The code is as follows:
$. / ext_skel-extname=my
B. Enter the my module:
The code is as follows:
$cd my
C. Modify the config.m4 file and find the following:
The code is as follows:
Dnl PHP_ARG_WITH (my, for my support
Dnl Make sure that the comment is aligned:
Dnl [--with-my Include my support])
Remove the previous dnl, and finally as follows:
The code is as follows:
PHP_ARG_WITH (my, for my support
Make sure that the comment is aligned:
[--with-my Include my support])
Then save the file.
Tips: if you need to test whether the modification is correct, you can use php my.php to test it:
The code is as follows:
$php my.php
Confirm_my_compiled
Congratulations! You have successfully modified ext/my/config.m4. Module my is now compiled into PHP.
The above confirm_my_compiled is the default function of the module, and after loading the module, you can call this function.
3. Compiler module
Or execute the following command in the directory of the my module:
The code is as follows:
$phpize
$. / configure
$make
$make install
When the compilation is successful, you will be prompted with the following message:
The code is as follows:
Installing shared extensions: / usr/lib/php5/20090626+lfs/
Indicates that the module has been compiled and copied to the php module directory.
Tips: if the phpize command is not found, you need to install php5-dev and install OK using apt-get directly under ubuntu.
The code is as follows:
$apt-get install php5-dev
4. Load module
Edit the file:
The code is as follows:
$vim / etc/php5/conf.d/my.ini
Add the following to load the my.so module, and then save it.
The code is as follows:
Extension=my.so
Restart apache
The code is as follows:
$/ etc/init.d/apache2 restart
In the web environment, you can use phpinfo to see if the my module is loaded. The terminal can be viewed using php-I | less.
5. Write the test program
If all goes well, the my module is loaded and confirm_my_compiled, the default method of the my module, can be called. Write a php test file:
The code is as follows:
Echo confirm_my_compiled ("Hello")
Execute the test file, and if you see the output below, it will be successful.
The code is as follows:
Congratulations! You have successfully modified ext/my/config.m4. Module Hello is now compiled into PHP.
Thank you for reading this article carefully. I hope the article "how to use c to write php expansion module in ubuntu12.04" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.