Php extension installation method in linux

Source: Internet
Author: User
Tags imagemagick php website
In linux, php extension installation methods:
1. Compile with PHP
2. generate a separate. so file
The second method is introduced here. the execution efficiency of the second method may be lower, but the modularization means that php can be used without changing the php installation. ini connects to the separately generated so file for extension,
For example, if you have installed php using the tar package, you want to add the following extensions:

Install CURL extension
I. generate dynamic link library file. SO
The method is as follows:
Method 1. apt-get install php5-curl
Method 2: Go to the PHP website to download the tar package and phpize the local compilation to generate. so
Method 3: install the program in pear mode. use the pecl command to download the program and generate. so

Method 1 is the simplest in ubuntu. after the command is executed, the directory of. so will be notified.

II. configure php. ini
Open php. ini: specifies the extension_dir Directory. if extension_dir = '/usr/lib', the generated. so file (such as curl. so) copy to the/usr/lib directory and add a new entry:
Extension = curl. so

III. make it take effect
Restart apache and run phpinfo () to check whether it takes effect.

Install PDO_MYSQL extension

Install using pear
I. install pear
Apt-get install php-pear if no pear exists, install pear first.

II. install pdo and pdo_mysql
Pecl install pdo pecl install pdo_mysql
Generate a. so file and copy it to the/usr/lib directory.

If php and mysql development kits are not installed, you need to install
Apt-get install php5-devapt-get install libmysqlclient15-dev

III. modify the configuration file php. ini
Add entry
Extension = pdo. so
Extension = pdo_mysql.so
IV. make it take effect
Restart apache and run phpinfo () to check whether it takes effect.

In php5.2.10, php has already installed pdo by default. Therefore, extension = pdo. so is not added, but it does not match the pdo_mysql.so generated by itself. the solution is as follows:
Reinstall php, add the parameter -- disable-pdo to disable the pdo module, and generate pdo. so with your own, pdo + mysql. so will be OK.

Install ImageMagic extension

Install using pear
I. install ImageMagick
Sudo apt-get install imagemagick

II. install the lib of imagemagick for php to call
Sudo apt-get install libmagick ++-dev

III. call the current pecl to install imagick
Pecl install imagick

IV. modify php. ini. restart apache server
Add extension = imagick. so to php. ini.

Install phpize

Phpize is the content of php-devel, so you only need to run
Apt-get install php-devel. In ubuntu, apt-get install php-dev is used.

I installed a php5-dev.

After installation, you can use phpize5 to install your own php extensions.

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.