Curl in php.ini but not loading Linux Mint 20

I am trying to get cURL to work on the above system.

In the php.ini it says that curl is enabled, and when I do in the terminal:

curl -V

I get:

curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1j 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

which I guess is the right response.

However, when I try to use a simple php script beginning with:

$curl = curl_init();

I get:

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/user/code_and_data_feb_2018/lex-code-november-2021/voice1.php:13 Stack trace: #0 {main} thrown in /home/user/code_and_data_feb_2018/lex-code-november-2021/voice1.php on line 13

which is the line of the above code.

When I try:

php -r “print_r(get_loaded_extensions());”
Array
(
[0] => Core
[1] => date
[2] => libxml
[3] => openssl
[4] => pcre
[5] => zlib
[6] => filter
[7] => hash
[8] => json
[9] => pcntl
[10] => Reflection
[11] => SPL
[12] => session
[13] => standard
[14] => sodium
[15] => mysqlnd
[16] => PDO
[17] => bz2
[18] => calendar
[19] => ctype
[20] => exif
[21] => FFI
[22] => fileinfo
[23] => ftp
[24] => gettext
[25] => iconv
[26] => imagick
[27] => mysqli
[28] => pdo_mysql
[29] => Phar
[30] => posix
[31] => readline
[32] => shmop
[33] => sockets
[34] => sysvmsg
[35] => sysvsem
[36] => sysvshm
[37] => tokenizer
[38] => Zend OPcache
[39] => xdebug

No mention of curl.

Where can it be?

PB

Solved. Two versions of php - 8.0 and 8.1. The former works in the terminal and the latter in the browser - I needed to:

sudo apt-get install php8.1-curl

to get it to work in the terminal:

php -r “print_r(get_loaded_extensions());”
Array
(
[0] => Core
[1] => date
[2] => libxml
[3] => openssl
[4] => pcre
[5] => zlib
[6] => filter
[7] => hash
[8] => json
[9] => pcntl
[10] => Reflection
[11] => SPL
[12] => session
[13] => standard
[14] => sodium
[15] => mysqlnd
[16] => PDO
[17] => bz2
[18] => calendar
[19] => ctype
[20] => curl
[21] => exif
[22] => FFI
[23] => fileinfo
[24] => ftp
[25] => gettext
[26] => iconv
[27] => imagick
[28] => mysqli
[29] => pdo_mysql
[30] => Phar
[31] => posix
[32] => readline
[33] => shmop
[34] => sockets
[35] => sysvmsg
[36] => sysvsem
[37] => sysvshm
[38] => tokenizer
[39] => Zend OPcache
[40] => xdebug

PB

2 Likes