How to add extension libraries for PHP in Linux

Source: Internet
Author: User

What problems will occur when I add them, and what errors will be reported if I do not add them. Therefore, when compiling PHP, many parameters are not added except the necessary directory settings ...... When I installed the web program, I found that many parameters need to be added, but I have already set up lnmp and do not want to re-compile and reinstall it .. So I found this article online.

1. add FTP Extension

1. Find the original source code package and decompress it.
Such as: php-5.2.13
Go to the FTP extension directory/root/lnmp/php-5.3.0/ext/ftp

2. Call the phpize program to generate the compilation configuration file.

Copy codeThe Code is as follows: root @ dns ftp] #/usr/local/php5/bin/phpize
Processing ing:
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 configure passes this step, run the make command. If configure fails, find the cause of the error.

# Make

# After make is successfully executed, the generated extension library file is in the modules subdirectory of the current directory,

Copy codeThe Code is as follows: [root @ Ansen ftp] # ls modules/
Ftp. la ftp. so

4. Edit the php. ini file, create the extension_dir directory, and copy the compiled extension file to the extension directory.

Change extension_dir = "./"

Copy codeThe Code is as follows: extension_dir = "/usr/local/php5/lib/php/extension"

Copy codeThe Code is as follows: [root @ Ansen modules] # cp ftp. so/usr/local/php5/lib/php/extension

5. Add the extension library location in php. ini and set the extension library to be added.
Add extension = ftp. so in section 989

6. Restart apache to get ftp support.

Ii. Add zlib Extension

Copy codeThe Code is 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 apache.

PS: for other extensions, refer to the above two extension methods for installation.

Supplemented with the simplified version:

I forgot to compile php at the beginning. Now I am using phpize to install the extension library and add it.
Locate the source code directory of the currently running php version, such as the php-5.2.12. Enter the curl extension library directory
# Cd/home/changyou/php-5.2.12/ext/curl
(Call the phpize program to generate the compilation 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 configure passes this step, execute the make command. If configure fails, find the cause of the Error)
# Make
After make is successfully executed, the generated extension library file is in the modules subdirectory of the current directory.
My directory here is:/home/changyou/php-5.2.12/ext/curl/modules/curl. so
Configure the php. ini file and copy the compiled extension library file to the extension directory of php.
# Cp/home/changyou/php-5.2.12/ext/curl/modules/curl. so/usr/local/web/php/lib/php/extension/
Finally, modify php. ini to add the 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.