Linux to add an extension library to PHP _linux

Source: Internet
Author: User
Tags curl zend

Plus what will be the problem, do not report what is wrong, so when compiling PHP, in addition to the necessary directory specified, many parameters are not added ... When I installed the Web program, I found that a lot of parameters are to be added, but I lnmp have been built, do not want to recompile, reinstall. So I found this article on the Internet.

One, add FTP extension

1, to find the original source package decompression
such as: php-5.2.13
Access to the extended directory to FTP/root/lnmp/php-5.3.0/ext/ftp

2, call the Phpize program to generate the compilation configuration file

Copy Code code as follows:

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 to perform the following configure and make commands, respectively.

#./configure--with-php-config=/usr/local/php5/bin/php-config

#configure这一步执行通过后, the Make command is executed and the cause of the error is found if configure execution does not pass.

#make

#make成功执行后, the generated extension library file is in the modules subdirectory of the current directory,

Copy Code code as follows:

[Root@ansen ftp]# ls modules/
Ftp.la ftp.so

4, edit the php.ini document, create the Extension_dir directory, copy the compiled extension file to extension below

Change the Extension_dir = "./" To

Copy Code code as follows:

Extension_dir = "/usr/local/php5/lib/php/extension"

Copy Code code as follows:

[Root@ansen modules] #cp ftp.so/usr/local/php5/lib/php/extension

5, in the php.ini add the extension library location, set the expansion library to add.
Add extension=ftp.so at 989

6, restart the Apache can get FTP support

Second, add zlib extension

Copy Code code as follows:

[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, restart the Apache can be

PS: Other extensions can refer to the above two extended methods for installation

Supplemental Compact version:

When I started compiling php, I forgot to add it now with the phpize installation extension
Locate the source directory for the currently running PHP version, such as php-5.2.12. Enter the Curl Extension Library directory
#cd/home/changyou/php-5.2.12/ext/curl
(Invoke the Phpize program to generate the compilation configuration file)
#/usr/local/web/php/bin/phpize
(Compile the extension library, execute the following configure and make commands, respectively)
#./configure–with-php-config=/usr/local/web/php/bin/php-config
( Configure after this step is passed, the make command is executed, and if configure does not pass, find the cause of the error)
#make
Make is successfully executed, and the resulting extension library file is in the modules subdirectory of the current directory
As my directory here is:/home/changyou/php-5.2.12/ext/curl/modules/curl.so
Then configure the php.ini file to copy the compiled extension library files to the extension directory in PHP
#cp/home/changyou/php-5.2.12/ext/curl/modules/curl.so/usr/local/web/php/lib/php/extension/
Last modified php.ini add configuration
Extension_dir = "/usr/local/web/php/lib/php/extension/"
extension=curl.so

Done!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.