Today when I was making some modifications and additions to my Raspberry Pi Screen Project, I discovered a problem when trying to use CURL to pull an XML file in PHP on the Raspberry Pi. I was getting some errors which I wasn’t getting when testing on my web hosting.

[Sat Jun 05 10:43:14.842144 2021] [php7:error] [pid 1369] [client] PHP Fatal error: Uncaught Error: Call to undefined function curl_setopt() in /var/www/html/fit.php:5\nStack trace:\n#0 /var/www/html/index.php(55): include()\n#1 {main}\n thrown in /var/www/html/fit.php on line 5
[Sat Jun 05 10:43:53.405886 2021] [mpm_prefork:notice] [pid 516] AH00171: Graceful restart requested, doing restart

  1. First find what version of PHP you are running. Open a terminal and type the command php -version
  2. Here I am running 7.3 so I will use the line sudo apt-get install php7.3-curl
  3. If you have a different version of PHP, run the line that is correct for you.
  • PHP 7.4: sudo apt-get install php7.4-curl
  • PHP 7.3: sudo apt-get install php7.3-curl
  • PHP 7.2: sudo apt-get install php7.2-curl
  • PHP 7.1: sudo apt-get install php7.1-curl
  • PHP 7.0: sudo apt-get install php7.0-curl