Home >Backend Development >PHP Tutorial >Detailed explanation of how to install curl template in PHP_PHP tutorial

Detailed explanation of how to install curl template in PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:47:331136browse

curl is a file transfer tool using URL syntax, supporting FTP, FTPS, HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE and LDAP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploads, Kerberos, HTTP-based uploads, proxies, cookies, user+password authentication, file transfer recovery, http proxy channels and a host of other useful tricks.

After PHP is installed, the curl function extension is not enabled by default. You can enable this function extension in the following steps.

windows installation curl


1. Open the PHP installation directory, search for the following three files: ssleay32.dll, libeay32.dll and php_curl.dll, and copy them one by one to the system32 folder in the system directory,

2. Modify the php.ini file, find the ;extension= php_curl.dll line, remove the preceding ; number, save and restart the server.
3. To test, create a PHP file in the site directory with the following content

The code is as follows Copy code
 代码如下 复制代码

$ch = curl_init(“http://www.bKjia.c0m”);
curl_exec($ch);
curl_close($ch);

$ch = curl_init(“http://www.bKjia.c0m”);

curl_exec($ch); curl_close($ch);

linux installation curl

If the originally compiled php directory is in the /usr/local/php5 directory;

apache is in the /usr/local/apache2 directory;

The php source code is in the /home/kevin125/src directory.

If the actual directory is inconsistent with the assumed directory, make adjustments in the following command.

1. Find the source code directory of the currently running php version, such as php-5.2.10.
 代码如下 复制代码
$cd /home/kevin125/src/php-5.2.10/ext/curl

Enter the curl extension library directory.

 代码如下 复制代码
$/usr/local/php5/bin/phpize

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

 代码如下 复制代码
$./configure –with-php-config=/usr/local/php5/bin/php-config

3. Compile the extension library and execute the configure and make commands below respectively.

After the configure step is passed, execute the make command. If the configure execution fails, find the cause of the error.

$make


After make is executed successfully, the generated extension library file will be in the modules subdirectory of the current directory, such as /home/kevin125/src/php-5.2.10/ext/curl/modules/curl.so

 代码如下 复制代码
$cp /home/kevin125/src/php-5.2.10/ext/curl/modules/curl.so /usr/local/apache2/modules/
4. Configure php.ini file Copy the compiled extension library files to the apache2 modules directory.

Find the directory location where the php.ini file is located, and then edit it. You can determine the location of the php.ini file by viewing phpinfo information.
Find the location where the extension directory is set in the php.ini file, and then set the extension path to the apache2 modules directory

 代码如下 复制代码
extension_dir = “/usr/local/apache2/modules/”

In php.ini, set the extension library location and set the extension library to be added.

 代码如下 复制代码
extension=curl.so

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632849.htmlTechArticlecurl is a file transfer tool using URL syntax, supporting FTP, FTPS, HTTP HTTPS SCP SFTP TFTP TELNET DICT FILE and LDAP. curl supports SSL certificate, HTTP POST, HTTP PUT, FTP upload, kerb...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn