Home  >  Article  >  Backend Development  >  How to install php curl on ubuntu

How to install php curl on ubuntu

藏色散人
藏色散人Original
2020-11-01 13:35:121756browse

How to install php curl on ubuntu: first download the curl installation package; then install cURL; and finally turn on the switch "–with-curl=/usr/local/curl".

How to install php curl on ubuntu

Recommendation: "PHP Video Tutorial"

php installation curl extension library under ubuntu

If PHP has been compiled in the system and new extensions need to be added later, one way is to completely recompile PHP, and the other way is to compile the extension library separately and extend it in the form of extension.

Situation 1: New installation of php and curl

First download the curl installation package (I downloaded curl-7.33.0.tar.gz, some versions have problems during compilation, this should Depends on the php version)

Then install cURL

# tar -zxf (此处填下载的curl包名称)
# ./configure –prefix=/usr/local/curl
# make; make install

When installing php, just turn on the switch –with-curl=/usr/local/curl.

PHP requires that the curl directory must have include and lib directories, and there must be two files easy.h and curl.h under include, and libcurl.a must be under lib. After compilation, the files in the include directory are there, but they may not be in the lib directory yet. It was originally generated in the lib/.libs directory, so it needs to be copied to the lib directory.

Situation 2: PHP has been installed, now you need to add this extension

cd $PHP_PATH/ext/curl (其中$PHP_PATH为php源码安装包目录)
phpize
 ./configure –with-curl=DIR   (可以不写dir,如果你的curl安装时没有指定目录)
make

The curl.so file will be generated under PHPDIR/ext/curl/moudles/.

Copy the curl.so file to the extensions configuration directory and just modify php.ini

# tar -zxf (此处填下载的curl包名称)
# ./configure –prefix=/usr/local/curl
# make; make install

The above is the detailed content of How to install php curl on ubuntu. For more information, please follow other related articles on the PHP Chinese website!

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