Sabbir Rupom
Sabbir Rupom

Reputation: 43

PHP curl is not working through command line but working fine in browser call

I have launched a PHP based web application in AWS EC2 instance using ubuntu 16.04. I need to add some cron jobs for executing php file having curl feature. But while testing, the php shows following error while executing through command line:

PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in /var/www....php

but when I try to call the exact file through browser, it works perfectly.

I have checked php.info and it shows curl is enabled. Then I execute " php -m " command in terminal. It does not show curl among the list.

I opened the php.ini file, and enabled the php-curl extension which was commented out. But still its not executing through command line.

Previously in AWS EC2 I used ubuntu 14.04 and there I have not faced this problem at all.

Can anybody help me on this problem? Thanks in advance.

Upvotes: 1

Views: 919

Answers (1)

Sabbir Rupom
Sabbir Rupom

Reputation: 43

I have found the solution.

It looks like I have installed both php7 and php5.6. As I am working with php 5.6, I have enabled all its module but not in php7.0. The command ' php ' is set to php 7 cli. So for using version 5.6 I have to use command ' php5.6 ' instead of ' php ' for executing files

so the command will be like:

php5.6 /var/www....php

Upvotes: 0

Related Questions