Jagrati
Jagrati

Reputation: 12222

cURL not working even after trying so many solutions found on stackOverflow

I am using php7.0. I have installed curl in my system. I have this file:

/etc/php/7.0/cli/conf.d/20-curl.ini

I also have this file:

/etc/php/7.0/mods-available/curl.ini

Also, when I run this php -i | grep curl I get:

/etc/php/7.0/cli/conf.d/20-curl.ini,
curl

cat 20-curl.ini gives :

; configuration for php curl module
; priority=20
extension=curl.so

I even restarted my apache many times using sudo service apache2 restart

However, when I do var_dump(curl_init()) it says Call to undefined function curl_init().

I looked at various solution on stackOverflow, but can't find a solution that solves my problem. I am looking for the solution for hours. Can't understand how to make it work. I even tried sudo apt-get upgrade and upgraded my server.

I found in some solutions to uncomment ;extension=php-curl.dll but that is also not working. I am really stuck now. Need Help.

Upvotes: 1

Views: 513

Answers (2)

Jagrati
Jagrati

Reputation: 12222

The Solution is here: (I found the error in apache error log)

Although I shifted to php 7, I did not configure my apache to use php7 . So I did following:

sudo apt install php libapache2-mod-php
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart 

Upvotes: 1

Yannis Berrouag
Yannis Berrouag

Reputation: 356

you modified php.ini for the cli executable, not the one used by apache. you should have a etc/php7.0/apache2/php.ini file this is the one to update

Upvotes: 1

Related Questions