3

I have a Linux server with Ubuntu 16.04 installed. I usit just for LAMPP environment, I have PHP 5.6 installed (in apache and CLI), that because the project crash with PHP7, so, I have to maintain in 5.6 version. I'm trying to run a PHP script from the CLI, and I gets: curl_init() in unkown function. So, I went to the php.ini file (the one of the CLI) and unable the extension, but in CLI when I make: php --version I get:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/php_curl.dll' - /usr/lib/php/20131226/php_curl.dll: cannot open shared object file: No such file or directory in Unknown on line 0

Then I tried to install curl with: sudo apt-get install php5-curl but then I get:

E: Unable to locate package php5-curl

So, what should I do then? How can I install it?thanks

Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115

4 Answers4

8

I got the same issue you need to add this repository

sudo add-apt-repository ppa:ondrej/php
sudo apt update
Mr world wide
  • 4,696
  • 7
  • 43
  • 97
5

try running i have same issue solved by this command

 sudo apt-get install php-curl
M Maavia
  • 340
  • 1
  • 9
  • yes, I already made that and everything perfect. Then in the console I typed: `curl --help` and its installed. So I'm starting to believe that I hace to replace the directory where the dll is located, but I don't know how to find the current location – Sredny M Casanova Jan 27 '17 at 22:19
  • on ubuntu terminal curl is already install but we have to enable it in php.ini file you can build a page which show phpinfo() function and on top you will see directory where you have to include the code as in my mechine that is /etc/php/7.0/apache2 – M Maavia Jan 27 '17 at 22:21
1

In Ubuntu 16.04 default PHP version is 7.0, if you want to use different version then you need to install PHP package according to PHP version:

1-> PHP 7.0: sudo apt-get install php7.0-curl
2-> PHP 7.1: sudo apt-get install php7.1-curl
3-> PHP 7.2: sudo apt-get install php7.2-curl
4-> PHP 5.5: sudo apt-get install php5.5-curl
5-> PHP 5.6: sudo apt-get install php5.6-curl
Vishal Thakur
  • 1,564
  • 16
  • 25
1
  1. add this repository

    sudo add-apt-repository ppa:ondrej/php

    sudo apt update

  2. select your php version 5.5, 5.6,7.0, 7.2

    PHP 5.6: sudo apt-get install php5.6-curl

  3. Test curl enabled or disabled

    create index.php and add this code

    echo 'Curl: ', function_exists('curl_init') ? 'Enabled' : 'Disabled';

Jayendran
  • 9,638
  • 8
  • 60
  • 103
Ghanshyam Nakiya
  • 1,602
  • 17
  • 24