skip to Main Content

I’m using the ondrej ppa for PHP and am running Ubuntu 18. Running php -v gives me the following output:

PHP Warning:  PHP Startup: Unable to load dynamic library 'curl.so' (tried: /usr/lib/php/20190902/curl.so (/usr/lib/php/20190902/curl.so: symbol curl_mime_addpart version CURL_OPENSSL_4 not defined in file libcurl.so.4 with link time reference), /usr/lib/php/20190902/curl.so.so (/usr/lib/php/20190902/curl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

Basically, I can’t run any composer commands because a lot of libraries depend on curl, and apparently it isn’t being found. I’ve done the following:

  1. Tried to update everything (sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get install php7.4-curl). This doesn’t fix the issue.

  2. Restarted apache despite this being the cli version.

  3. Double checked where it’s trying to find the library. What’s weird is that /usr/lib/php/20190902/curl.so is a valid path and the file is definitely there.

Running php --ini also shows that the curl extension is loaded:

Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File:         /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed:      /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
...more ini files...
/etc/php/7.4/cli/conf.d/20-curl.ini,
...more ini files...

I’m unsure how to fix this as the file it supposedly can not find is exactly where it says it looked, and everything is up to date.

4

Answers


  1. Chosen as BEST ANSWER

    For anyone with this issue, the answer is here.

    Basically, the libcurl that was installed on my Ubuntu machine clashed with the official one that Ubuntu has? Weirdly it was only affecting php7.3 and 7.4 and not 7.2. Anyways, I renamed the libcurl module like so:

    mv /usr/local/lib/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4.4.0.backup

    And by running php -m, I could verify that the cURL module was now enabled.


  2. I found that if I did:
    apt search | more
    (the pipe is for long lists)
    that I could find the php package name that I needed.

    For example:
    apt search curl
    told me that the name of the package for my php version is ‘php7.2-curl’

    So, all I had to do was sudo apt install php7.2 curl.
    I repeated this (some names require a little googling, and/or some apt search creativity.

    Login or Signup to reply.
  3. I solved it by doing this:

    1. Uninstall curl:
    apt remove php7.4-curl
    
    1. New install:
    apt install php7.4-curl
    

    I have now all right.

    Login or Signup to reply.
  4. After trying to run composer update things were failing because the deps where from php -v 7 while I was using 8.

    composer install --ignore-platform-reqs
    

    worked for me

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search