Method to add an extension library to PHP under Linux
- 2020-05-06 12:07:37
- OfStack
Plus what will go wrong, do not add what will report wrong; So when compiling PHP, many parameters are not added except for the necessary directory specification... When I installed the web program, I found that many parameters are to be added, but I lnmp has been built, and I do not want to recompile, reinstall. So I found this article
on the Internet
1. Add FTP to extend
1. Find the original source package and unpack
Such as: php - 5.2.13
Into the FTP extensions directory/root/lnmp/php - 5.3.0 / ext/ftp
2. Call phpize program to generate the compiled configuration file
root@dns ftp]# /usr/local/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
3. Compile the extension library and execute the following configure and make commands, respectively.
#./configure --with-php-config=/usr/local/php5/bin/php-config
After this step #configure passes, the make command is executed. If configure fails, the reason for the error is found.
#make
After the successful execution of #make, the generated extension library file is in the modules subdirectory of the current directory,
[root@Ansen ftp]# ls modules/
ftp.la ftp.so
4. Edit the php.ini document, create the directory of extension_dir, and copy the compiled extension file to
under extension
Change extension_dir = "./" to
extension_dir = "/usr/local/php5/lib/php/extension"
[root@Ansen modules]#cp ftp.so /usr/local/php5/lib/php/extension
5. At the add library location of php.ini, set the extension library to be added.
Add extension= ftp.so at 989
6, restart apache to get ftp support
extension
[root@Ansen zlib]# pwd
/root/lnmp/php-5.3.0/ext/zlib
[root@Ansen zlib]#mv config0.m4 config.m4
[root@Ansen zlib]#/usr/local/php5/bin/phpize
[root@Ansen zlib]#./configure --with-php-config=/usr/local/php5/bin/php-config
[root@Ansen zlib]#make
[root@Ansen zlib]# cp modules/zlib.so /usr/local/php5/lib/php/extension/
[root@Ansen zlib]#vi /usr/local/php5/lib/php.ini
add extension=zlib.so
8. Just restart apache
PS: other extensions can refer to the above two extensions to install
added succinct edition:
When you first compiled php, you forgot to add
with the phpize installation extension library
Find the source code directory for the currently running php version, such as php-5.2.12. Go to curl extension library directory
#cd /home/changyou/php-5.2.12/ext/curl
(call the phpize program to generate the compile configuration file)
#/usr/local/web/php/bin/phpize
(compile the extension library and execute the following configure and make commands, respectively)
#. / configure � with - php - config = / usr/local/web/php/bin/php - config
After the configure step passes, the make command is executed. If the configure execution fails, the reason for the error is found
#make
After the successful execution of make, the generated extension library file is
in the modules subdirectory of the current directory
As I the directory: / home/changyou/php 5.2.12 / ext curl/modules/curl so
Then configure the php.ini file and copy the compiled extension library file to
in the extension directory of php
#cp /home/changyou/php-5.2.12/ext/curl/modules/curl.so /usr/local/web/php/lib/php/extension/
Last modified php.ini to add configuration
extension_dir = "/ usr local/web/php/lib/php/extension/"
extension=curl.so
Done!!!