I get a undefined curl_version() function in php - php

I added Paypal Express checkout plugin to my website.
I get this error:
2019-07-23T15:45:32+00:00 CRITICAL Uncaught Error: Call to undefined
function PayPal\Core\curl_version() in
/var/www/html/wp-content/plugins/woo-paypal-express-checkout/includes/php-library/paypal-rest/lib/PayPal/Core/PayPalHttpConfig.php:65
and this is the line
$curl = curl_version();
What can I do to resolve this probleme
I tried to install php-curl but I always got the same result
I used
sudo apt-get install php5-curl
sudo service apache2 restart

It sounds like you are missing the PHP CURL extension. This is usually bundled as a separate package. If you are using Ubuntu, apt-get install php-curl (or php7.2-curl) will install the missing dependency. You may need to enable the module after installing it using phpenmod curl. If you are using another Linux distribution, please consult the appropriate distribution documentation for installing PHP modules.

First, check your active PHP version, maybe there are multiple PHP versions installed on the server. In that case, you have to look for an active PHP version running on the server. Use phpinfo(); to check PHP version. Then run the command as per your PHP version. In my case, it was PHP 7.3.
$ sudo apt-get install php7.3-curl
$ sudo service apache2 restart

Related

PHP: Cleanly upgrading/replacing PHP from unavailable repository on Ubuntu 12.04

I am running an Ubuntu 12.04 Apache2/PHP/MYSQL server that was using a deprecated version of PHP. I realized this once I tried to install the sqlite3 extension I get an error:
Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/precise/main/source/Sources
Research shows me that this is no longer used and instead use ondrej/php instead. This is a production server and I need to figure out steps to replace the PPA with the correct one.
Will I need to uninstall PHP and reinstall using the new packages? If so how should I go about doing this cleanly?
Is there a way to temporarily install sqlite3 without having to change repositories completely (I do not have php-dev installed at the moment either).
First you should check if there are any compatibility issues with the version you want to upgrade to (did a quick google to find this: https://github.com/squizlabs/PHP_CodeSniffer). Then, add the repository that contains the version you want, sudo apt-get update and install the version of php you want. To switch the version apache uses, do the following:
sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart

Php7 Installation of wordpress on nginx throwing PHP installation missing MySQL extension which is required by WordPress

How can I fix this? im trying to do a clean install of wordpress latest on ubuntu 16 running nginx for Php7
When i access :
http://blog.mysite.com/wordpress/
I get:
Your PHP installation appears to be missing the MySQL extension which
is required by WordPress.
How can i resolve this?
Simply install necessary extensions and restart fpm process:
sudo apt-get install php-mysqlnd php-mysqli
sudo /etc/init.d/php7.0-fpm restart
This is a real relief I found this post, which helped me:
How to enable MySQLi extension in php 7?
Basically, if you're running php7 instead of php5 you should run this to resolve this issue:
sudo apt-get install php-mysql
and yes, as #Kris mentioned:
reload your webserver

Fatal error: Call to undefined function mcrypt_get_block_size()

I am uploading my website on to a server, and it uploaded successfully. After that, when I run, it gives me this error:
Fatal error: Call to undefined function mcrypt_get_block_size().
I also check my PHP version on my server is 5.3.14. I couldn't figure out how I can deal with this. I used this function for query string encryption. I searched about this on Google and some people say you have to ask your host to install it. Is there another way to install this or alternate function that work just like this mcrypt_get_block_size()?
You have to install and enable mcrypt.
On a Debian based Linux distribution (like Ubuntu), run this from command line:
sudo apt-get install php5-mcrypt
As Alex said, you need to install the library, but don't forget to enable it.
sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo /etc/init.d/apache2 restart

Can't get mongo.so extension to load after updating PHP to 5.3

I had PHP 5.2 with MongoDB installed on Debian Lenny x64 and everything was fine.
After updating PHP to 5.3 (dotdeb) I can't get MongoDB to work, I always get an error
Fatal error: Class 'Mongo' not found (...)
Everything else works fine, all default modules are working.
My php.ini:
extension_dir = "/usr/lib/php5/20090626"
extension=mongo.so
Mongo.so is in same location as written above.
But when I run php -m in console to check loaded modules, "mongo" isn't listed there.
I can't use dl('mongo.so') to load module at runtime, because this function was deprecated in PHP 5.3.
May be I should recompile mongo somehow, I just don't know how to do that because I'm not very good in *nix commands.
Thanks for your help!
UPDATE
Also may be it's worth saying that before my mongo.so was in /usr/lib/php5/20060613 and I manually copied it to "/usr/lib/php5/20090626" because it seems that after updating my PHP all modules are located there.
The extension module api has changed between php5.2 and php5.3. When php tries to load an extension module both sides have to "present" an api magic key that identifies the api version. If those numbers don't match the module is not loaded/activated.
Try sudo pecl install mongo again to get an extension module that fits your new php version.
Try re installing mongo & restart service
sudo pecl uninstall mongo
sudo pecl install mongo
sudo service apache2 restart
This will install mongo in to newer version
I spent a little time trying to fix this, I am guessing you had a previous mongo install. The way I fixed it was by:
I installed php5-dev:
sudo apt-get install php5-dev
cd /etc/php5/apache2/conf.d/
sudo rm -rf mongo.ini
I then viewed my php.ini and removed extension=mongo.so
Then:
sudo pecl uninstall mongo
sudo pecl install mongo
sudo service apache2 restart

Fatal error: Call to undefined function ldap_connect() in ubuntu

I'm trying to connect to my LDAP server via PHP, but I get the following error:
Fatal error: Call to undefined function ldap_connect()
Any help would be very appreciated.
Thanks in advance,
roshan
Make sure the LDAP extension is installed and enabled. This answer assumes you have PHP5, however, things should work similarly for PHP7 as well.
Install LDAP Extension
There should be a package named like php5-ldap:
aptitude show php5-ldap
Paquet : php5-ldap
...
Description : LDAP module for php5
This package provides a module for LDAP functions in PHP scripts.
Thus, the package can usually be installed like:
sudo apt-get install php5-ldap
If you do not use apt-get, use the equivalent command for the package manager you use.
Enable LDAP Extension
To enable the package after installation, you can use this command:
sudo php5enmod ldap
If you get any error message from the above command, it means something went wrong.
Note: After enabling the package, you usually have to restart / reload services so that the newly enabled module is recognized. For apache, you can do this by:
sudo service apache2 restart
If you do not use apache, please use the equivalent command for your server.
sudo apt-get install php5-ldap
And don't afraid to google.

Categories