Two methods of PHP5 installation Curl expansion under CentOS system

Source: Internet
Author: User
Tags curl fpm zts centos

php5.3 Installation Curl Extension

The code is as follows Copy Code

Tar zxf Decompression
./configure--prefix=/usr/local/curl
Make
Make install

Enter the source code package of PHP, if not, download php5.3.tar.gz decompression can be.

The code is as follows Copy Code

CD Ext/curl

Run the phpize.
/usr/local/php5/bin/phpize

Configure Curl

The code is as follows Copy Code
./configure--with-php-config=/usr/local/php5/bin/php-config--with-curl=/usr/local/curl
Make
Make install

Enter Modules Directory
CD modules

Copy curl.so to PHP's extended directory

The code is as follows Copy Code

CP curl.so/usr/local/php5/lib/php/extensions/curl.so

Open php.ini

The code is as follows Copy Code

Vi/usr/local/php5/etc/php.ini

Add a line:
extension=/usr/local/php5/lib/php/extensions/curl.so

: Wq Save
Restart the service, because I am using fastcgi, so I restart the php-fpm can be.
KILL-USR2 ' Cat/usr/local/php5/var/run/php-fpm.pid '


install PHP5 Extension Curl

1. Install Crul

The code is as follows Copy Code
wget http://curl.haxx.se/download/curl-7.19.6.tar.gz
TAR-ZXVF curl-7.19.6.tar.gz
CD curl-7.19.6
./configure--prefix=/usr/local/curl
Make
Make install

2.Linux PHP Compile Build extension

Into the Linux PHP source directory in the Ext directory, where the source code for each extension module, select the module you need, such as Curl module: CD Curl execution phpize build compile files, phpize in the PHP installation directory in the bin directory/usr/local /php5/bin/phpize run, you may have an error: Cannot find autoconf. Please check your autoconf installation and the $PHP _autoconf,environment variable are set correctly and then rerun this SC Ript. ", you need to install Autoconf:yum install autoconf (redhat or CentOS), Apt-get install autoconf (Ubuntu Linux)

Build configuration file and Linux PHP build module:

The code is as follows Copy Code
/usr/local/php5/bin/phpize
./configure--with-curl=/usr/local/curl--with-php-config=/usr/local/php5/bin/php-config
Make
Make install

In this way, curl.so is copied to the PHP directory (for example:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/)

3.Linux PHP Modify Configuration

In Linux php.ini, set extended directory: Extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/" and add Extension Module reference: extension = curl.so

Here you can also set the extended directory without this designation, PHP. INI default extension directory is:/usr/local/php5/lib/php/extensions/, here the curl.so to the CP here, add extension=curl.so on the line.

4. Check and restart Apache
/usr/local/php/bin/php-v execute this command, Linux PHP will check the configuration file is correct, if there is a configuration error, there will be errors, can be based on error information to troubleshoot the same.

PHP Source Installation Curl Extension

Premise:
(1) You may set up PHP has been installed, the directory for/home/work/php5210/
(2) You may set the PHP source directory for/home/work/php-5.2.10/
(3) You may set the PHP Bin directory has been added to the environment variables, directory for/home/work/php5210/bin, and has included PHP, Phpize, php-config and other binary
(4) Not to set up Linux system has been installed curl, the second system for/usr/bin/curl

Installation steps:

The code is as follows Copy Code
# Enter the PHP source directory
cd/home/work/php-5.2.10
# into the Curl Extended source directory
Cd/home/work/php-5.2.10/ext/curl
# phpize Configuration
# If the hint cannot find the phpize, the path to Phpize is not included in the environment variable
Phpize
# Configure the path of the Linux bin
# If the hint cannot find the php-config, the path to Php-config is not included in the environment variable
./configure–with-curl=/usr/bin/curl
# Compile
# If successful, the curl.so will be generated in the modules directory
Make
# copy curl.so to PHP extentions
CP modules/curl.so/home/work/php5210/lib/php/extensions/no-debug-non-zts-20060613/
# Modify PHP.ini configuration, join
Extentions=curl.so


test is effective:

The code is as follows Copy Code

<?php
if (function_exists (' Curl_init ')) {
echo "1";
}else{
echo "0";
}

If the input is 1 or the installation succeeds, the installation fails.

Related Article

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.