curl not available in php CLI on Ubuntu 16.04 - php

I have curl installed and running on php for Apache2. On command line however it does not work:
$ php test.php
PHP Fatal error: Uncaught Error: Call to undefined function curlhttp()
checking for curl:
$ php -i | grep curl
/etc/php/7.0/cli/conf.d/20-curl.ini,
curl
having a deeper look:
cat /etc/php/7.0/cli/conf.d/20-curl.ini
; configuration for php curl module
; priority=20
extension=curl.so
where is the library anyway?
$ locate curl.so
/usr/lib/php/20151012/curl.so
/usr/lib/x86_64-linux-gnu/libcurl.so
/usr/lib/x86_64-linux-gnu/libcurl.so.3
/usr/lib/x86_64-linux-gnu/libcurl.so.4
/usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0
which php version?
$ php -v
PHP 7.0.33-0ubuntu0.16.04.15 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-0ubuntu0.16.04.15, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Let's check SO for a solution:
How to install php-curl in Ubuntu 16.04
trying to reinstall:
sudo apt install php7.0-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-curl is already the newest version (7.0.33-0ubuntu0.16.04.15).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
$ sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.47.0-1ubuntu2.14).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
I don't see the problem. What might be the cause and how can this be fixed?

Related

Install gRPC for PHP

I want to install gRPC for PHP 7.3. I followed Google Cloud documentation.
I use ubuntu 16.04, Nginx
I install:
sudo apt-get install autoconf zlib1g-dev php-dev php-pear
sudo pecl install grpc
But I am getting this error:
No releases available for package "pecl.php.net/grpc"
install failed
I don't know what is wrong.
It is php -v
PHP 7.3.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 9 2020 06:46:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Please, help me.

MongoClient on 32-bit Linux and PHP < 7 without refactoring

I have an error saying MongoClient class is not found.
I've tried both the instructions on the MongoDB website and these answers.
Upon php -v there is
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongo.so'
PHP 5.6.30-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
with sudo grep -rnw /etc -e "mongo.so"
I have
/etc/php/5.6/fpm/php.ini:2033:extension=mongo.so
/etc/php/5.6/cli/php.ini:2032:extension=mongo.so
/etc/php/5.6/apache2/php.ini:2033:extension=mongo.so
Then I tried the manual installation.
When I run phpize
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
At the make test output I get
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
How do I compile the correct module?
I've removed php 7 entirely
sudo apt-get purge php7.*
I guess you had installed the wrong extension for your system.
I suggest to start fresh and use pecl to install and compile mongo extension properly.
Install pecl (assuming that you are using Debian-based distribution with correct apt repos, pecl comes bundled with php-pear)
sudo apt-get install php5-dev php-pear
Install the legacy mongo driver from pecl
sudo pecl install mongo
Add extension=mongo.so on php.ini
sudo su
echo "extension=mongo.so" >> /etc/php5/mods-available/mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/30-mongo.ini
Note that the legacy driver is not compatible with PHP 7+ and the lastest version of MongoDB one can use with this driver is 3.0. See the compatibility chart from MongoDB Docs.

Attempted to call function "curl_init"

I know this question was answered a lot of times here but I tried many things and I cannot fix it.
I am developing using symfony 3.
First of all I thought I hadn't php-curl so, I decided to install it doing
sudo apt-get install php-curl
It worked! So, I restarted Apache... and tried again.. and the error jumped again. I saw too I should "delete" the ; of a php.ini line but... surprise! There is not any line with:
;extension=php_curl.dll
I thought then maybe I didn't really install php-curl... so I did:
var_dump(extension_loaded('curl'));
And the answer is:
Current PHP version: 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1
EDIT: I followed this:
And now appears
Current PHP version: 5.6.26-1+deb.sury.org~xenial+1
Then I tried to:
sudo apt-get install php5-curl
And is happens:
tureey#tureey:~$ sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
Actually these are my software stats:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
And after do:
php -v
PHP 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I did and upgrade and update but nothing changes... any solution?
Correct package should be php5.6-curl

How to install xdebug in ubuntu 16.04 in netbeans?

Whenever I try to run this code
example#testserver:~$ sudo apt-get install php5-xdebug
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-xdebug
I get this error "E: Unable to locate package php5-xdebug"
Please help
Thanks
If you're running the default apt installation of PHP on Ubuntu 16.04, then it should be PHP7. If I had to guess from php5-xdebug, then I'd say you were using a command intended for Ubuntu 14.04 or older where the default PHP installation was PHP5. You can verify your PHP version with:
php --version
This is what I see:
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
At any rate, you should be able to search available packages for your configuration with:
apt search xdebug
From my relatively fresh Ubuntu 16.04 install without any added PPA's, I get one result:
php-xdebug - Xdebug Module for PHP
So you can install this package by name (note the missing "5" from your command):
sudo apt install php-xdebug
You might also have to restart your webserver. If you're running the stock build of Apache for Ubuntu 16.04:
sudo service apache2 restart

Install fileinfo extenstion of PHP failed

I followed this tutorial:
$ apt-get install php-pear php5-dev libmagic-dev
$ pecl install fileinfo
$ sudo echo "extension=fileinfo.so" > /etc/php5/fileinfo.ini
$ sudo apachectl restart
But when I run this, it said failing message:
root#111:~/mine/Fileinfo-1.0.4# pecl install fileinfo
WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/fileinfo/in php sources"
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
3 source files, building
WARNING: php_bin /alidata/server/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Cannot find config.m4.
Make sure that you run '/alidata/server/php/bin/phpize' in the top level source directory of the module
ERROR: `phpize' failed
Here is my machine information:
root#111:~/mine/Fileinfo-1.0.4# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise
Here is my PHP version information:
root#111:~/mine/Fileinfo-1.0.4# php --version
PHP 5.4.27 (cli) (built: Jun 12 2014 22:20:06)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

Categories