I am trying to install php-curl in my terminal but this command show

    linux@Lenovo:~$ sudo apt-get install php-curl 

    Reading package lists... Done Building dependency tree       
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
        The following packages have unmet dependencies:  
    php-curl : Depends: php7.4-curl but it is not going to be installed 
    E: Unable to correct problems, you have held broken packages.
  • What OS & release are you using?
    – guiverc
    Oct 11, 2020 at 22:03
  • linux ubuntu...
    – Ananda
    Oct 11, 2020 at 22:04
  • Again what release are you using? I can rmadison php-curl but until I know your release, the detail from that query will lead to different conclusions/advice depending on your stated release.
    – guiverc
    Oct 11, 2020 at 22:05
  • I Use php 7.4..
    – Ananda
    Oct 11, 2020 at 22:07
  • Again what release are you using?
    – guiverc
    Oct 11, 2020 at 22:07

3 Answers 3


You can add it via the ondrej/php PPA:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.4-curl
  • Seems that has gone - E: Unable to locate package php7.4-curl
    – malhal
    May 25 at 11:19

There are a number of issues posted here on AskUbuntu about older features of PHP such as CURL, and the procedure oriented functions for SQL database access, which do not work on Ubuntu 20.04 and PHP 7.4 out of the box.

It would appear that evangelists for more modern features have chosen to deprecate older feature implementations, even though there is nothing in the PHP documentation to hint that these features are deprecated. These older interfaces are used by many existing applications and therefore should either be in the supported repositories, or a clear pointer must be provided to alternatives that are supported which require rewriting the code to modern standards. In particular there is nothing in the PHP documentation for curl_init to suggest that it is not a standard feature of PHP, and the recommended way to exchange information over the Internet. There is not even a reference to stream_context_create which can be used with fopen, readfile, or SplFileObject. For example instead of curl_... you can use the following, adapted from contributions to the documentation page for stream_context_create:

$opts = array(
        'http' => array (
              "Accept-language: en\r\n".
              "Content-type: application/x-www-form-urlencoded\r\n",

$context = stream_context_create($opts);

$fp = fopen('https://www.example.com', 'r', false, $context);

In my opinion, and clearly the opinion of the people who contributed to the packaging of Ubuntu 20.04, it is much clearer to use the newer interfaces. I just added a user contributed note to the PHP documentation of curl_init to that effect.

sudo apt update
sudo apt install php7.4-curl
sudo service apache2 restart

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.