257

I've installed PHP 7 using this repo, but when I try to run composer install, it's giving this error:

  • [package] requires ext-curl * -> the requested PHP extension curl is missing from your system.

With PHP 5, you can easily install it by running the yum or apt-get install php5-curl command, but I can't find how to install the PHP 7 equivalent.

How do I install ext-curl for PHP 7?

3
  • 3
    install libcurl first ie. yum install libcurl or apt-get install libcurl. After that configure your php 7 with curl ./configure --with-curl and finally make and install Jan 30, 2016 at 4:33
  • @Haridarshan Yea okay, but that's inconvenient
    – The Onin
    Feb 3, 2016 at 9:04
  • I've build and install php 7 with curl and other extension. You may also need to install devel libraries. Feb 3, 2016 at 9:16

12 Answers 12

571

Well I was able to install it by :

sudo apt-get install php-curl

on my system. This will install a dependency package, which depends on the default php version.

After that restart apache

sudo service apache2 restart
6
  • 37
    ..and restart the service. sudo service apache2 restart
    – Sydwell
    Sep 9, 2016 at 16:11
  • 2
    Only if you are using the apache webserver version. You don't need to restart apache for the CLI version of course
    – CommandZ
    Sep 24, 2016 at 17:51
  • similarly gd2, xmlrpc, soap, etc - all small letters suffix worked
    – msanjay
    Oct 25, 2016 at 15:43
  • 5
    Instead of sudo service apache2 restart, sudo service apache2 reload
    – sudip
    May 16, 2017 at 18:40
  • 1
    This actually depends on the packages available in the APT sources. First, update the APT packages using apt-get update. Then type apt-get install php and press tab twice. It will ask for a confirmation to display the whole list like Display all n possibilities? (y or n): where N is the available number of possibilities. Press Y and you'll get a long list of available packages, out of which you can find the package name that you want. O course, if you have a long list, this will be a little tedious. But still you can narrow it down based on the version. Aug 18, 2017 at 6:41
126
sudo apt-get install php7.0-curl
6
  • 10
    you shouldn't specify the version number if you dont explicitly need it. otherwise you might accidentally install an older version.
    – phil294
    Dec 16, 2016 at 0:07
  • 4
    Code-only and "try this" answers are discouraged. I'm surprised it took you so long to get a single downvote.
    – RamenChef
    Dec 18, 2016 at 1:23
  • 3
    In my case, I had to specify the version for it to work. I guess this is because I had more than one versions installed in my system. Dec 28, 2016 at 14:16
  • 1
    If upgrading from PHP 5.5/5.6 specifying the version number seems to be required.
    – AlexL
    Jun 23, 2017 at 18:09
  • had to additionally do sudo apt install curl anyone know why that is so? Aug 9, 2017 at 6:50
30

If "sudo apt-get install php-curl" command doesnt work and display error We should run this code before install curl.

  • step1 - sudo add-apt-repository ppa:ondrej/php
  • step2 - sudo apt-get update
  • step3 - sudo apt-get install php-curl
  • step4 - sudo service apache2 restart
3
  • 1
    I don't know why people downvoted this, give it a go, it may work. Aug 31, 2017 at 23:31
  • 1
    Yep, it works. BTW on step 3 you can actually pick a specific php version.
    – iliaz
    Feb 10, 2018 at 17:13
  • 2
    sometimes it needs to specify version of your php. for example: step3 sudo apt-get install php7.1-curl p.s. you save me from a long night ! Aug 25, 2018 at 20:16
28

I tried the above solutions but it didn't work for me, just incase there any other person in the same shoes, this is what I did. I updated apt-get with the following command

sudo add-apt-repository ppa:ondrej/php

this i installed with php curl for the version of php that i was using, mine was

sudo apt-get install php7.1-curl

If this didn't work for you, the repository can be removed with:

sudo add-apt-repository --remove ppa:ondrej/php
3
  • 1
    Other answers led me to the exact same conclusion. Let's say it's correct for Now, where other answers were correct for their own time. I'll verify that this works for Ubuntu 18.04, Apache 2. This is preferable to the simple "php-curl" which attempts to load a PHP7.2 version, where (for me) I want to keep using 7.1. Don't forget to restart the webserver. After this, where phpinfo() used to show cURL just under the Module Authors section ( Sterling Hughes ), now cURL has it's own very detailed section, currently at 7.58.0.
    – TonyG
    Oct 2, 2018 at 2:58
  • you are the real hero
    – Berk Kaya
    Nov 11, 2018 at 7:52
  • 1
    This should be the accepted answer. The answer with more votes didn't helpe me. Nov 26, 2018 at 17:19
15

We can install any PHP7 Extensions which we are needed at the time of install Magento just use related command which you get error at the time of installin Magento

sudo apt-get install php7.0-curl
sudo apt-get install php7.0-dom
sudo apt-get install php7.0-mcrypt
sudo apt-get install php7.0-simplexml
sudo apt-get install php7.0-spl
sudo apt-get install php7.0-xsl
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-ctype
sudo apt-get install php7.0-hash
sudo apt-get install php7.0-openssl
sudo apt-get install php7.0-zip
sudo apt-get install php7.0-xmlwriter
sudo apt-get install php7.0-gd
sudo apt-get install php7.0-iconv
4
  • Your answer doesn't add any value. Apr 25, 2018 at 14:03
  • Your answer doesn't contain any new information. Please see the other answers. Apr 25, 2018 at 20:03
  • 4
    This is a very good answer, as person looking for curl will likely have next question on his mind about mcrypt. And so on, so it is very useful to have everything there. Sep 3, 2018 at 5:12
  • Why are these extensions suddenly missing? How to install them in standalone Windows using PHP.ini? Jul 18, 2021 at 12:46
14

If You have 404 or errors while sudo apt-get install php-curl just try

sudo apt-get update

and again try

sudo apt-get install php-curl

But notice what version was installed (i use php7.3 and php7.4-curl was installed - so it will not work)

try then

sudo apt-get install php7.3-curl

At the end You may want to restart services like: apache2 or php-fpm:

sudo apache2 restart
sudo service php7.3-fpm restart

this worked for me.

Check if curl is on the installed modules list for current php:

php -m

enter image description here

1
  • 1
    Curl is installed, but not in that list... now what? Edit php.ini? (total newb here) Feb 7, 2022 at 22:48
4

If you are using PHP7.1 ( try php -version to find your PHP version)

sudo apt-get install php7.1-curl

then restart apache

sudo service apache2 restart
1
  • 1
    I prefer this answer since it specifies the version number. The accepted answer is not very accurate.
    – Aaron Liu
    Mar 26, 2019 at 18:18
4

First Login to your server and check the PHP version which is installed on your server.

And then run the following commands:

sudo apt-get install php7.2-curl

sudo service apache2 restart

Replace the PHP version ( php7.2 ), with your PHP version.

3

I got an error that the CURL extension was missing whilst installing WebMail Lite 8 on WAMP (so on Windows).

After reading that libeay32.dll was required which was only present in some of the PHP installation folders (such as 7.1.26), I switched the PHP version in use from 7.2.14 to 7.1.26 in the WAMP PHP version menu, and the error went away.

1
  • I had to do this as well to get CURL to work. (I tried copying libeay32.dll from version 7.0.10 into 7.3.8 folder, but didn't work.) Not sure why this library file is missing from new php 7.3.8 installation.
    – Stefan
    Nov 7, 2019 at 10:17
2

install php70w-common.

It provides php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib.

https://webtatic.com/packages/php70/

0
1

Windows users:

Note: Note to Win32 Users In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll, or, as of OpenSSL 1.1 libcrypto-.dll and libssl-.dll, must be present in your PATH. Also libssh2.dll must be present in your PATH. You don't need libcurl.dll from the cURL site.

https://www.php.net/manual/en/curl.installation.php

Add your C:\wamp\bin\php\php7.1.15 to your PATH

Restart all services

-1

Try it if you get E: Unable to locate package {packageName}

sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php-curl
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.