0

I have an apache server and want to add curl.

I have done

sudo apt-get update
sudo apt-get install curl (successfully completed)
sudo apt-get install php-curl (successfully completed)
sudo service apache2 restart

And I get this:

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

Am I missing a step? This post (How do I install the ext-curl extension with PHP 7?) seem to indicate that it should be that easy


For info,

php --version

PHP 8.1.13 (cli) (built: Nov 26 2022 14:07:36) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.13, Copyright (c) Zend Technologies with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies

curl -V

curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3 Release-Date: 2020-01-08 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

Matt Welander
  • 8,234
  • 24
  • 88
  • 138
  • have you tried ... ```sudo apt install php-[version-number]-curl``` eg ```sudo apt install php7.1-curl``` if not available then you might need to install curl... – Anant V May 07 '23 at 12:57
  • 1
    Thank you. Seemed redundant to me to install both php-curl and php8.1-curl, is the former not necessary then or what does it do? – Matt Welander May 07 '23 at 13:20
  • _need to install curl._ ---- wrote that incorrectly.... there i wish to wrote you might need to add ondrej sury repo (recommended as well) if you do not find extension....Anyway as far as i know when you do ```php8.1-curl``` it will install the stable version for that particular version... else ```php-curl``` will install appropriate version... recommended method -> ```sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt install php8.1-curl``` request you to also check [this](https://stackoverflow.com/questions/38800606/how-to-install-php-curl-in-ubuntu-16-04) answer..... – Anant V May 07 '23 at 13:44
  • After installing a PHP extension, you also need to _enable_ it. On a Linux-based system, you do this by running `sudo phpenmod curl`. After that you may need to restart Apache again. – rickdenhaan May 07 '23 at 16:06

0 Answers0