The system is Ubuntu 12.04, already installed Apache and php,php version is 5.3.10.
The following actions are recommended to switch to root if you encounter permissions issues.
1. Download the source code
Check out the source code for PHP 5.3.10
Copy the Code code 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'll need to install SVN first, and use the Apt-get installation directly under Ubuntu OK:
Copy the Code code as follows:
$ sudo apt-get install subversion
For PHP source code, if you need more information, you can check the PHP wiki for the description of SVN: Https://wiki.php.net/vcs/svnfaq
2. Create a module
A, source check out, enter the source code ext directory, first create a module with Ext_skel, module named my:
Copy the Code code as follows:
$./ext_skel--extname=my
B. Enter my module:
Copy the Code code as follows:
$ cd My
C, modify the Config.m4 file, find the following content:
Copy the Code code as follows:
DNL Php_arg_with (My, for my support,
DNL Make sure, the comment is aligned:
DNL [--with-my Include my support]
To remove the previous DNL, the following is the last:
Copy the Code code as follows:
Php_arg_with (My, for my support,
Make sure, the comment is aligned:
[--with-my Include my support]
Then save the file.
Tips: If you need to test the correct changes, you can use PHP my.php to test:
Copy the Code code as follows:
$ PHP my.php
Confirm_my_compiled
congratulations! You have successfully modified EXT/MY/CONFIG.M4. Module My is now compiled to PHP.
The above confirm_my_compiled is the module default function, after the module is loaded, you can call this function.
3. Compile the module
Or, under the directory of my module, execute the following command:
Copy the Code code as follows:
$ phpize
$./configure
$ make
$ make Install
After the compilation is successful, this information is prompted:
Copy the Code code 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, need to install the next Php5-dev, in Ubuntu under the direct use of apt-get installation is OK.
Copy the Code code as follows:
$ apt-get Install Php5-dev
4. Loading module
To edit a file:
Copy the Code code as follows:
$ vim/etc/php5/conf.d/my.ini
Add the following to indicate that the my.so module is loaded and then saved.
Copy the Code code as follows:
Extension=my.so
Re-launch Apache
Copy the Code code as follows:
$/etc/init.d/apache2 Restart
In the Web environment, you can use Phpinfo to see if the My module is loaded. Terminal can use Php-i | Less view.
5. Write test procedures
If all goes well, then my module is loaded, and the default method of my module confirm_my_compiled can be called. To write a PHP test file:
Copy the Code code as follows:
Echo confirm_my_compiled ("Hello");
Execute the test file and if you see the output below, it will succeed.
Copy the Code code as follows:
congratulations! You have successfully modified EXT/MY/CONFIG.M4. Module Hello is now compiled to PHP.
http://www.bkjia.com/PHPjc/621656.html www.bkjia.com true http://www.bkjia.com/PHPjc/621656.html techarticle The system is Ubuntu 12.04, already installed Apache and php,php version is 5.3.10. The following actions are recommended to switch to root if you encounter permissions issues. 1, download source Check out ...