One of the nifty things about common open source software is that lots of people write down answers to their own problems. (Like I’m doing now.) The problem is that commands change, software gets moved between packages, etc. and it’s realy hard to figure out what actually applies to anything. PHP seems particularly problem to this problem because it’s old (in web-years) and because it’s popular in the blogging community, so it gets blogged about a lot. (Like I’m doing now.)

I have Pi 3 running DietPi for some internal IoT/network monitoring duty. DietPi works really well on a headless configuration, so I’ve used it forever.

I also have an internal page that has some super-simple PHP that cranks off CURL calls to build connections to other pages. After finally finding where logs are THIS month (/var/log/apache2/error.log), I was getting:

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/index.php:81\nStack trace:\n#0 /var/www/index.php(101): checkOnline()\n#1 /var/www/index.php(194): checkAlive()\n#2 {main}\n thrown in /var/www/index.php on line 81

php.ini definitely had extension=curl (not libcurl, not libcurl.so, not php8.3-curl, not the hundred other suggestions) and it was definitely being recognized because I could change the spelling of it and get different errors in the log. But whas I wasn’t getting was … curl.

Fast-forward about three hours.

dietpi@DietPi:~$ sudo apt-get install php8.3-curl php 8.2-curl
(and I notice now that it even fixed my typo. What a rare act of kindness from Linux CLI administration. 🙂

This is a total act of desparation because I can absolutely see the curl.so object in the /usr/lib/php/20220829/ extension_dir that’s helpfully provided by phpinfo(). But let’s try….

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Note, selecting ‘php8.2-curl’ for regex ‘8.2-curl’
Note, selecting ‘php8.2-curl-dbgsym’ for regex ‘8.2-curl’
php8.3-curl is already the newest version (8.3.3-1+0~20240216.17+debian11~1.gbp87e37b).
php8.3-curl set to manually installed.
The following NEW packages will be installed:
php php8.2-curl php8.2-curl-dbgsym php8.3
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 223 kB of archives.
After this operation, 370 kB of additional disk space will be used.
Get:1 https://packages.sury.org/php bullseye/main armhf php8.3 all 8.3.3-1+0~20240216.17+debian11~1.gbp87e37b [27.6 kB]
Get:2 https://packages.sury.org/php bullseye/main armhf php all 2:8.3+94+0~20240205.51+debian11~1.gbp6faa2e [7,404 B]
Get:3 https://packages.sury.org/php bullseye/main armhf php8.2-curl armhf 8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3 [31.3 kB]
Get:4 https://packages.sury.org/php bullseye/main armhf php8.2-curl-dbgsym armhf 8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3 [157 kB]
Fetched 223 kB in 2s (146 kB/s)
Selecting previously unselected package php8.3.
(Reading database … 65559 files and directories currently installed.)
Preparing to unpack …/php8.3_8.3.3-1+0~20240216.17+debian11~1.gbp87e37b_all.deb …
Unpacking php8.3 (8.3.3-1+0~20240216.17+debian11~1.gbp87e37b) …
Selecting previously unselected package php.
Preparing to unpack …/php_2%3a8.3+94+0~20240205.51+debian11~1.gbp6faa2e_all.deb …
Unpacking php (2:8.3+94+0~20240205.51+debian11~1.gbp6faa2e) …
Selecting previously unselected package php8.2-curl.
Preparing to unpack …/php8.2-curl_8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3_armhf.deb …
Unpacking php8.2-curl (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …
Selecting previously unselected package php8.2-curl-dbgsym.
Preparing to unpack …/php8.2-curl-dbgsym_8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3_armhf.deb …
Unpacking php8.2-curl-dbgsym (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …
Setting up php8.2-curl (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …

Creating config file /etc/php/8.2/mods-available/curl.ini with new version
Setting up php8.3 (8.3.3-1+0~20240216.17+debian11~1.gbp87e37b) …
Setting up php (2:8.3+94+0~20240205.51+debian11~1.gbp6faa2e) …
Setting up php8.2-curl-dbgsym (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …
Processing triggers for libapache2-mod-php8.2 (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …
Processing triggers for php8.2-cli (8.2.16-1+0~20240216.40+debian11~1.gbp6cbea3) …
dietpi@DietPi:~$ sudo systemctl restart apache2

Viola! Sucess.

35+ years of administering UNIX-y systems and the darned things can still stump me some times. In this case, it’s actually distracting just how much documentation there is for queries like “dietpi Call to undefined function curl_init()” but the problem is the answers are for distros that no longer exist and PHP versions ranging from 7 to 5 to even 4 and, of course, the names of everything changing alont the way, the preferred web server changing from Nginx back to Apache, etc.

So here’s my attempt to litter the web with yet more search results, but hopefully this helps the next “me” that’s trying to get an updated system working again at 3am.