[Ubuntu] How to add PHP extension after installed PHP?

Source: Internet
Author: User
Tags php source code
Let's say you installed PHP and run it for a month, but now you want the use of curl in PHP.

But so bad, you didn ' t install the This extension if you installed PHP. That's to say,

Now you want to add PHP extension.

Here is a example to install Curl extension.

Apache2 is In/usr/local/apache2

PHP is in/usr/lib/php5/

1. Install the CURL

Download The Curl source code from:http://curl.haxx.se/download, here is curl-7.17.1.tar.gz.

Then uncompress and install it.

TAR-ZXF curl-7.17.1.tar.gz
./configure--prefix=/usr/local/curl
sudo make
sudo make test
sudo make install

Here we install the Curl To/usr/local/curl

2. Install the Php5-curl

*note:you should has the PHP source code, otherwise the steps can ' t ' go on. Assume that the PHP source code

is in ~/downloads/php-5.2.10-src, and you should has installed the phpize.

CD ~/downloads/php-5.2.10-src/ext/curl/
Phpize
./configure--with-php-config=php-config--with-curl=/usr/local/curl
sudo make
sudo make test
sudo make install

Then you'll find curl.so in ~/downloads/php-5.2.10-src/ext/curl/modules. Copy it to the PHP extension folder, here is/usr/lib/php5/20060613+lfs/

sudo cp ~/downloads/php-5.2.10-src/ext/curl/modules/curl.so/usr/lib/php5/20060613+lfs/curl.so

3. Modify the php.ini file

Add the code to php.ini

Extension=curl.so

4. Restart the Apache

Sudo/etc/init.d/apache2 restart

Then the curl extension is installed.

  • 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.