Question

cURL is NOT installed in my PHP7 installation

  • Posted May 23, 2016
  • PHP

I am running a script and I have this Fatal error: Call to undefined function curl_init() in /var/www/html/wp-content/plugins/accesspress-social-login-lite/twitter/twitteroauth.php on line 189

it appears curl is not enabled in my install, how may I go about it?

Subscribe
Share

to get the list of all available php modules on my server, I typed

aptitude search php7-

No list showed up: Then I typed

aptitude search php5-

and the full list of modules was displayed. Then I ran the command below:

aptitude install php5-curl
The following NEW packages will be installed:
  php5-curl
The following packages will be upgraded:
  php5-common
1 packages upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
Need to get 472 kB of archives. After unpacking 143 kB will be used.
The following packages have unmet dependencies:
 libapache2-mod-php5 : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.5.9+dfsg-1ubuntu4.16 is to be installed.
 php5-mysql : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.5.9+dfsg-1ubuntu4.16 is to be installed.
 php5-readline : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.5.9+dfsg-1ubuntu4.16 is to be installed.
 php5-cli : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.5.9+dfsg-1ubuntu4.16 is to be installed.
 php5-gd : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.14) but 5.5.9+dfsg-1ubuntu4.16 is to be installed.
The following actions will resolve these dependencies:

     Remove the following packages:
1)     libapache2-mod-php5
2)     php5
3)     php5-cli
4)     php5-gd
5)     php5-mysql
6)     php5-readline

     Leave the following dependencies unresolved:
7)     libapache2-mod-php5 recommends php5-cli


Accept this solution? [Y/n/q/?] y
The following NEW packages will be installed:
  php5-curl
The following packages will be REMOVED:
  fontconfig-config{u} fonts-dejavu-core{u} libapache2-mod-php5{a}
  libfontconfig1{u} libgd3{u} libjbig0{u} libjpeg-turbo8{u} libjpeg8{u}
  libtiff5{u} libvpx1{u} libxpm4{u} php5{a} php5-cli{a} php5-gd{a}
  php5-mysql{a} php5-readline{a}
The following packages will be upgraded:
  php5-common
1 packages upgraded, 1 newly installed, 16 to remove and 67 not upgraded.
Need to get 472 kB of archives. After unpacking 26.7 MB will be freed.
Do you want to continue? [Y/n/?] y
Get: 1 http://mirrors.digitalocean.com/ubuntu/ trusty-updates/main php5-common amd64 5.5.9+dfsg-1ubuntu4.16 [445 kB]
Get: 2 http://mirrors.digitalocean.com/ubuntu/ trusty-updates/main php5-curl amd64 5.5.9+dfsg-1ubuntu4.16 [27.4 kB]
Fetched 472 kB in 3s (144 kB/s)
(Reading database ... 91911 files and directories currently installed.)
Removing php5-gd (5.5.9+dfsg-1ubuntu4.14) ...
php5_invoke prerm: Disable module gd for apache2 SAPI
php5_invoke prerm: Disable module gd for cli SAPI
Removing libgd3:amd64 (2.1.0-3) ...
Removing libfontconfig1:amd64 (2.11.0-0ubuntu4.1) ...
Removing fontconfig-config (2.11.0-0ubuntu4.1) ...
Removing fonts-dejavu-core (2.34-1ubuntu1) ...
Removing php5 (5.5.9+dfsg-1ubuntu4.14) ...
Removing libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.14) ...
php5_invoke prerm: Disable module json for apache2 SAPI
php5_invoke prerm: Disable module mysqli for apache2 SAPI
php5_invoke prerm: Disable module pdo_mysql for apache2 SAPI
php5_invoke prerm: Disable module pdo for apache2 SAPI
php5_invoke prerm: Disable module opcache for apache2 SAPI
php5_invoke prerm: Disable module readline for apache2 SAPI
php5_invoke prerm: Disable module mysql for apache2 SAPI
Module php5 disabled.
apache2_invoke prerm: Disable module php5
 * Restarting web server apache2                                                AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
                                                                         [ OK ]
Removing libtiff5:amd64 (4.0.3-7ubuntu0.4) ...
Removing libjbig0:amd64 (2.0-2ubuntu4.1) ...
Removing libjpeg8:amd64 (8c-2ubuntu8) ...
Removing libjpeg-turbo8:amd64 (1.3.0-0ubuntu2) ...
Removing libvpx1:amd64 (1.3.0-2) ...
Removing libxpm4:amd64 (1:3.5.10-1) ...
Removing php5-readline (5.5.9+dfsg-1ubuntu4.14) ...
php5_invoke prerm: Disable module readline for cli SAPI
Removing php5-cli (5.5.9+dfsg-1ubuntu4.14) ...
php5_invoke prerm: Disable module json for cli SAPI
php5_invoke prerm: Disable module mysqli for cli SAPI
php5_invoke prerm: Disable module pdo_mysql for cli SAPI
php5_invoke prerm: Disable module pdo for cli SAPI
php5_invoke prerm: Disable module opcache for cli SAPI
php5_invoke prerm: Disable module mysql for cli SAPI
Removing php5-mysql (5.5.9+dfsg-1ubuntu4.14) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
(Reading database ... 91761 files and directories currently installed.)
Preparing to unpack .../php5-common_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking php5-common (5.5.9+dfsg-1ubuntu4.16) over (5.5.9+dfsg-1ubuntu4.14) ...
Selecting previously unselected package php5-curl.
Preparing to unpack .../php5-curl_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking php5-curl (5.5.9+dfsg-1ubuntu4.16) ...
Setting up php5-common (5.5.9+dfsg-1ubuntu4.16) ...
Setting up php5-curl (5.5.9+dfsg-1ubuntu4.16) ...

Creating config file /etc/php5/mods-available/curl.ini with new version

Current status: 67 updates [-9].

Unfortunately, the frontend of my site is now a blank white screen. Is there any way to resolve this. I server is ubuntu 14.04


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

run the following command

apt-get install php7.0-curl

Hi,

How can I install curl in 7.1 version but doesn’t work and generate the error log:

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

Please help me with the problem and working fine my code.

Hello,

If you’re using Nginx or Apache on Ubuntu 20 droplet:

Install PHP libraries for the server by running the following command:

sudo add-apt-repository ppa:ondrej/php

sudo apt update

sudo apt install curl

Check the version of curl installed by the command:

dpkg -l curl

You need to restart your webserver on which PHP is running: If you are using Apache server then use either of the following commands to restart the server:

sudo service apache2 restart

or

sudo /etc/init.d/apache2 restart

Similarly, if you are using Nginx server, then use either of the following commands:

sudo systemctl restart nginx

or

sudo /etc/init.d/nginx restart

Hope that this helps! Regards, Alex

Yes. Working perfectly too. Thanks

Depending on your distribution, install curl with one of the following:

On CentOS or other yum based package systems

  • yum install php-curl
  • yum install curl

On Debian or other apt-get based package systems

  • apt-get install curl
  • apt-get install libcurl
  • apt-get install php-curl

I haven’t used php7 as of yet. However, as newbie states above, you might try installing curl using apt-get install php7-curl or yum install php7-curl.