Home >Backend Development >PHP Tutorial >Detailed explanation of how to install curl template in PHP_PHP tutorial
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 | ||||
curl_exec($ch); curl_close($ch); |
linux installation curl
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/ |
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 |