Related
I have to install php5-curl in my OpenWrt. I followed the steps of the official site
When I type, I see available packages:
$ opkg list php5*
but, I don't see php5-culr or php-curl. However, I change the line:
;extension=sockets.so
To:
extension=sockets.so
In php.ini file And also, add a file php_curl.ini in etc/php5/ and restart the server (lighttpd) and nothing happened.
Any help to get CURL in OpenWrt?
I try PHP Post Request inside a POST Request thinking it might be useful for me. My code is given below:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
from the index.php file and index2.php is another file in the same directory and when I open the page I get the following error in my error.log file:
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
What I want to do is to have a reservation form that send post request. Then I want to process post values and send again the post request to paypal.
You need to install CURL support for php.
In Ubuntu you can install it via
sudo apt-get install php5-curl
If you're using apt-get then you won't need to edit any PHP configuration, but you will need to restart your Apache.
sudo /etc/init.d/apache2 restart
If you're still getting issues, then try and use phpinfo() to make sure that CURL is listed as installed. (If it isn't, then you may need to open another question, asking why your packages aren't installing.)
There is an installation manual in the PHP CURL documentation.
For Windows, if anybody is interested, uncomment the following line (by removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
I got it working in ubuntu 16.04 by following steps.My php version was 7.0
sudo apt-get install php7.0-curl
sudo service apache2 restart
i got it from this link check here for more details
For Ubuntu:
add extension=php_curl.so to php.ini to enable, if necessary. Then sudo service apache2 restart
this is generally taken care of automatically, but there are situations - eg, in shared development environments - where it can become necessary to re-enable manually.
The thumbprint will match all three of these conditions:
Fatal Error on curl_init() call
in php_info, you will see the curl module author (indicating curl is installed and available)
also in php_info, you will see no curl config block (indicating curl wasn't loaded)
In my case, in Xubuntu, I had to install libcurl3 libcurl3-dev libraries. With this command everything worked:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the php-curl package, and yet Apache is still giving you the same error.
curl_init() undefined even if php-curl is enabled in Php 7.
Had this problem but found the answer here: https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
Had to:
sudo a2dismod php7.0
And:
sudo a2enmod php7.2
Then:
sudo service apache2 restart
This was after a system upgrade to next version of Ubuntu. All the other answers I found were stale, due to a bad cert apparently on the PPA most of them pointed out, but would probably not have worked anyway. The real issue was disabling the old versions of php, apparently.
Found the solution here:
https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
To fix this bug, I did:
In php.ini file, uncomment this line: extension=php_curl.dll
In php.ini file, uncomment this line: extension_dir = "ext"
I restarted NETBEANS, as I was using Built-in server
I got this error using PHP7 / Apache 2.4 on a windows platform. curl_init worked from CLI but not with Apache 2.4. I resolved it by adding LoadFile directives for libeay32.dll and ssleay32.dll:
LoadFile "C:/path/to/Php7/libeay32.dll"
LoadFile "C:/path/to/Php7/ssleay32.dll"
LoadFile "C:/path/to/Php7/php7ts.dll"
LoadModule php7_module "C:/path/to/Php7/php7apache2_4.dll"
This answer is for https request:
Curl doesn't have built-in root certificates (like most modern browser do). You need to explicitly point it to a cacert.pem file:
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cert/file/cacert.pem');
Without this, curl cannot verify the certificate sent back via ssl. This same root certificate file can be used every time you use SSL in curl.
You can get the cacert.pem file here: http://curl.haxx.se/docs/caextract.html
Reference PHP cURL Not Working with HTTPS
Step 1 :
C:/(path to php folder)/php.ini
enable extension=php_curl.dll
(remove the ; at the end of the line)
Step 2 :
Add this to Apache/conf/httpd.conf (libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder)
# load curl and open ssl libraries
LoadFile "C:/(path to php folder)/libeay32.dll"
LoadFile "C:/(path to php folder)/ssleay32.dll"
LoadFile "C:/(path to php folder)/libssh2.dll"
On newer versions of PHP on Windows, like PHP 7.x, the corresponding configuration lines suggested on previous answers here, have changed. You need to uncomment (remove the ; at the beginning of the line) the following line:
extension_dir = "ext"
extension=curl
(Trying to get Curl working via PHP and Apache on Windows...)
I kept getting an error saying:
Call to undefined function 'curl_init()'
I made sure I had enabled curl with this line in my php.ini file:
extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this:
extension_dir = "ext"
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I'd post in case it helps someone else.
For PHP 7 and Windows x64
libeay32.dll, libssh2.dll and ssleay32.dll should not be in apache/bin and should only exist in php directory and add php directory in system environment variable. This work for me.
Obvisouly in php.ini you should have enable php_curl.dll as well.
RusAlex answer is right in that for Apache you have to install and enable curl and restart your apache service:
sudo apt-get install php5-curl
sudo service apache2 restart
On my Ubuntu Server with nginx and php5-fpm I however ran into the following problem. I had to restart nginx and php5-fpm like so:
sudo service nginx restart
sudo service php5-fpm restart
But I had non-working php5-fpm processes hanging around, which apparently is a bug in ubuntu https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
So I had to kill all idle php5-fpm processes to able to restart php5-fpm so that the curl module is actually loaded
sudo kill <Process Id of php5-fpm Process)
function curl_int();
cause server error,install sudo apt-get install php5-curl
restart apache2 server .. it will work like charm
For linux you can install it via
sudo apt-get install php5-curl
For Windows(removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
On Ubuntu 18.04 these two commands solve my this problem.
sudo apt-get install php5.6-curl //install curl for php 5.6
sudo service apache2 restart //restart apache
Seems you haven't installed the Curl on your server.
Check the PHP version of your server and run the following command to install the curl.
sudo apt-get install php7.2-curl
Then restart the apache service by using the following command.
sudo service apache2 restart
Replace 7.2 with your PHP version.
I also faced this issue. My Operating system is Ubuntu 18.04 and my PHP version is PHP 7.2.
Here's how I solved it:
Install CURL on Ubuntu Server:
sudo apt-get install curl
Add the PHP CURL repository below to your sources list:
sudo add-apt-repository ppa:ondrej/php
Refresh your package database
sudo apt update
Install PHP-curl 7.2
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Restart Apache Server
sudo systemctl restart apache2
That's all.
I hope this helps
Yet another answer ...
If you land here in Oct 2020 because PHP on the command line (CLI) has stopped working, guess what ... some upgrades will move you to a different/newer version of PHP silently, without asking!
Run:
php --version and you might be surprised to see what version the CLI is running.
Then run:
ll /usr/bin/php and you might be surprised to see where this is linking to.
It's best to reference the SPECIFIC version of PHP you want when calling the PHP binary directly and not a symbolic link.
Example:
/usr/bin/php7.3 will give you the exact version you want. You can't trust /usr/bin/php or even just typing php because an upgrade might switch versions on you silently.
I have solved this issue in Ubuntu 20.04.1 LTS and PHP Version 7.4.3
Update the package index:
sudo apt-get update
Install php7.4-curl deb package:
sudo apt-get install php7.4-curl
This worked for me with raspian:
sudo apt update && sudo apt upgrade
sudo apt install php-curl
finally:
sudo systemctl restart apache2
or:
sudo systemctl restart nginx
To install the last version of php-curl on Ubuntu, use this:
sudo apt-get install php-curl -y
I'm trying to set up a cronjob which requires curl, and I'm calling it directly from crontab with
* * * * * /usr/bin/php myurl/my_cron.php
The problem is, it looks like the curl module isn't installed for my phpcli.
It works just fine when I hit the url from my browser, but when I run
php -q myfile.php
from the command line, it returns
PHP Fatal error: Call to undefined function curl_init() in my_cron.php on line 20
When I run php -m the curl module does not show up. However when I go to the browser and dump the php_info(), the module shows up and says its correctly installed.
The other kicker is i've been trying to install curl with apt-get onto the server (Ubuntu 12.04 php 5.4), it seems to take down my PHP as it begins to simply attempt to download the index.php file wherever I try to browse to.
Here are the attempts I've made to install curl that have taken down PHP:
sudo apt-get install php-curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
After each of these I restarted the apache2 server and still no dice, it attempted to download the file instead of opening the page.
How can I install php5-curl to just the cli, so that my server can run it and I don't have to go through a browser?
The other possibility is I could run the cronjobs through wget from the crontab file, but I've heard that's not the best option and potentially unreliable.
Any help is much appreciated. Thanks!
I had the same issue. But, finally I solved it by running the following command.
sudo apt-get install php7.0-curl
Restart the server after installing. This answer may not be useful for the user who asked because he asked it two months ago. But, this may be useful for the users who reading this in the future.
Here's how I've fixed this on ubuntu 14.04 when curl was working in php files run through apache, but not when called from the cli.
ssh to your server and cd to /
find / -name 'curl.so'
Run the above find command to locate where the curl binary is hanging out at. If you can't find the file, you might need to install curl and run the find command again.
apt-get install php5-curl
You'll now want to edit the php.ini being used for php files run from the cli (it's different than the one used by apache), and is likely at /etc/php5/cli/php.ini
nano /etc/php5/cli/php.ini
You can also run
php -i | grep 'php.ini'
To get the file path, just to be sure.
In your php.ini file search for [curl] by pressing ctrl + w
You'll now want to add the extension to the file and it should look something like the following, though your path to the curl.so file and such might be a little different:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =
extension=/usr/lib/php5/20131226/curl.so
After doing the above, I was able to use curl in php scripts run from the cli.
first find the version of your php cli by:
php -v
for example if it was version 7 then:
sudo apt-cache search php7
this will give you the proper module names for your current version:
php7.0-curl - CURL module for PHP <---- the name of curl module.
php7.0-dev - Files for PHP7.0 module development
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mysql - MySQL module for PHP
.
.
so on
so to add curl support, copy the name of curl module from the list above then do the following:
sudo apt-get install php7.0-curl
If you are using the command-line interface ('cli') for php5, instead of
php -q myfile.php
please use:
php5 -q myfile.php
php5-curl seems to enable the curl module for the cli php5 and not php and both (can) load different configurations and modules.
I use ubuntu 14.04 and php 5.3. After upgrading to php 5.6.29 I also has problem with php curl. My directory structure after updating to php 5.6.29:
/etc/php5 - old version (5.3)
/etc/php/5.6 - new version
The next command
sudo apt-get install php5-curl
didn't help (looks like it connects to old php version - 5.3).
I have found next article: php 5.6 for magento
It advice to use command
apt-get -y install php5.6-curl
instead of
apt-get -y install php5-curl
It works for me!
The first thing you should always check is your php.ini file. You should have a php.ini file in your web root. Curl is installed by default on most web servers; I haven't found a web server with PHP that hasn't already had curl installed. Its not always enabled, though.
Check your your php.ini file and search for php_curl.dll, it should look like this:
;extension=php_curl.dll
Just remove the semicolon (;) from before "extension" and save the file. It should work right away. According to your phpinfo.php its already installed, so it likely just needs to be enabled.
A similar question can be found here if you're interested: Call to undefined function curl_init()
In case someone reached here to find windows version of running curl.
Open php.ini and remove the ; before extension=php_curl.dll around line 656.
I am pretty much sure what Apache loads is C:\wamp\bin\apache\Apache2.2.17\bin\php.ini therefore you may find curl working from browser.
But when php is run from command line then it may show unknown function curl_init();
Run php -r "echo php_ini_loaded_file();" in the command line to see which ini file is being loaded.
Usually its found inside C:\wamp\bin\php\php5.3.5\php.ini its a different file from what Apache is using. So open it and then remove the ; before extension=php_curl.dll around line 656.
Hope it helps someone.
I try PHP Post Request inside a POST Request thinking it might be useful for me. My code is given below:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
from the index.php file and index2.php is another file in the same directory and when I open the page I get the following error in my error.log file:
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
What I want to do is to have a reservation form that send post request. Then I want to process post values and send again the post request to paypal.
You need to install CURL support for php.
In Ubuntu you can install it via
sudo apt-get install php5-curl
If you're using apt-get then you won't need to edit any PHP configuration, but you will need to restart your Apache.
sudo /etc/init.d/apache2 restart
If you're still getting issues, then try and use phpinfo() to make sure that CURL is listed as installed. (If it isn't, then you may need to open another question, asking why your packages aren't installing.)
There is an installation manual in the PHP CURL documentation.
For Windows, if anybody is interested, uncomment the following line (by removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
I got it working in ubuntu 16.04 by following steps.My php version was 7.0
sudo apt-get install php7.0-curl
sudo service apache2 restart
i got it from this link check here for more details
For Ubuntu:
add extension=php_curl.so to php.ini to enable, if necessary. Then sudo service apache2 restart
this is generally taken care of automatically, but there are situations - eg, in shared development environments - where it can become necessary to re-enable manually.
The thumbprint will match all three of these conditions:
Fatal Error on curl_init() call
in php_info, you will see the curl module author (indicating curl is installed and available)
also in php_info, you will see no curl config block (indicating curl wasn't loaded)
In my case, in Xubuntu, I had to install libcurl3 libcurl3-dev libraries. With this command everything worked:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the php-curl package, and yet Apache is still giving you the same error.
curl_init() undefined even if php-curl is enabled in Php 7.
Had this problem but found the answer here: https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
Had to:
sudo a2dismod php7.0
And:
sudo a2enmod php7.2
Then:
sudo service apache2 restart
This was after a system upgrade to next version of Ubuntu. All the other answers I found were stale, due to a bad cert apparently on the PPA most of them pointed out, but would probably not have worked anyway. The real issue was disabling the old versions of php, apparently.
Found the solution here:
https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
To fix this bug, I did:
In php.ini file, uncomment this line: extension=php_curl.dll
In php.ini file, uncomment this line: extension_dir = "ext"
I restarted NETBEANS, as I was using Built-in server
I got this error using PHP7 / Apache 2.4 on a windows platform. curl_init worked from CLI but not with Apache 2.4. I resolved it by adding LoadFile directives for libeay32.dll and ssleay32.dll:
LoadFile "C:/path/to/Php7/libeay32.dll"
LoadFile "C:/path/to/Php7/ssleay32.dll"
LoadFile "C:/path/to/Php7/php7ts.dll"
LoadModule php7_module "C:/path/to/Php7/php7apache2_4.dll"
This answer is for https request:
Curl doesn't have built-in root certificates (like most modern browser do). You need to explicitly point it to a cacert.pem file:
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cert/file/cacert.pem');
Without this, curl cannot verify the certificate sent back via ssl. This same root certificate file can be used every time you use SSL in curl.
You can get the cacert.pem file here: http://curl.haxx.se/docs/caextract.html
Reference PHP cURL Not Working with HTTPS
Step 1 :
C:/(path to php folder)/php.ini
enable extension=php_curl.dll
(remove the ; at the end of the line)
Step 2 :
Add this to Apache/conf/httpd.conf (libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder)
# load curl and open ssl libraries
LoadFile "C:/(path to php folder)/libeay32.dll"
LoadFile "C:/(path to php folder)/ssleay32.dll"
LoadFile "C:/(path to php folder)/libssh2.dll"
On newer versions of PHP on Windows, like PHP 7.x, the corresponding configuration lines suggested on previous answers here, have changed. You need to uncomment (remove the ; at the beginning of the line) the following line:
extension_dir = "ext"
extension=curl
(Trying to get Curl working via PHP and Apache on Windows...)
I kept getting an error saying:
Call to undefined function 'curl_init()'
I made sure I had enabled curl with this line in my php.ini file:
extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this:
extension_dir = "ext"
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I'd post in case it helps someone else.
For PHP 7 and Windows x64
libeay32.dll, libssh2.dll and ssleay32.dll should not be in apache/bin and should only exist in php directory and add php directory in system environment variable. This work for me.
Obvisouly in php.ini you should have enable php_curl.dll as well.
RusAlex answer is right in that for Apache you have to install and enable curl and restart your apache service:
sudo apt-get install php5-curl
sudo service apache2 restart
On my Ubuntu Server with nginx and php5-fpm I however ran into the following problem. I had to restart nginx and php5-fpm like so:
sudo service nginx restart
sudo service php5-fpm restart
But I had non-working php5-fpm processes hanging around, which apparently is a bug in ubuntu https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
So I had to kill all idle php5-fpm processes to able to restart php5-fpm so that the curl module is actually loaded
sudo kill <Process Id of php5-fpm Process)
function curl_int();
cause server error,install sudo apt-get install php5-curl
restart apache2 server .. it will work like charm
For linux you can install it via
sudo apt-get install php5-curl
For Windows(removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
On Ubuntu 18.04 these two commands solve my this problem.
sudo apt-get install php5.6-curl //install curl for php 5.6
sudo service apache2 restart //restart apache
Seems you haven't installed the Curl on your server.
Check the PHP version of your server and run the following command to install the curl.
sudo apt-get install php7.2-curl
Then restart the apache service by using the following command.
sudo service apache2 restart
Replace 7.2 with your PHP version.
I also faced this issue. My Operating system is Ubuntu 18.04 and my PHP version is PHP 7.2.
Here's how I solved it:
Install CURL on Ubuntu Server:
sudo apt-get install curl
Add the PHP CURL repository below to your sources list:
sudo add-apt-repository ppa:ondrej/php
Refresh your package database
sudo apt update
Install PHP-curl 7.2
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Restart Apache Server
sudo systemctl restart apache2
That's all.
I hope this helps
Yet another answer ...
If you land here in Oct 2020 because PHP on the command line (CLI) has stopped working, guess what ... some upgrades will move you to a different/newer version of PHP silently, without asking!
Run:
php --version and you might be surprised to see what version the CLI is running.
Then run:
ll /usr/bin/php and you might be surprised to see where this is linking to.
It's best to reference the SPECIFIC version of PHP you want when calling the PHP binary directly and not a symbolic link.
Example:
/usr/bin/php7.3 will give you the exact version you want. You can't trust /usr/bin/php or even just typing php because an upgrade might switch versions on you silently.
I have solved this issue in Ubuntu 20.04.1 LTS and PHP Version 7.4.3
Update the package index:
sudo apt-get update
Install php7.4-curl deb package:
sudo apt-get install php7.4-curl
This worked for me with raspian:
sudo apt update && sudo apt upgrade
sudo apt install php-curl
finally:
sudo systemctl restart apache2
or:
sudo systemctl restart nginx
To install the last version of php-curl on Ubuntu, use this:
sudo apt-get install php-curl -y
I am trying to use the new facebook api and it requires libcurl PHP. I used
sudo apt-get install php5-curl
sudo apachectl -k restart
And it didn't work. I get the same error and the phpinfo() page says nothing about libcurl.
The source of this problem is probably that I built some of the tools from source (apache2, php), but then I got bored so installed a lot of the extensions with the package manager. But I'm not exactly how to go about diagnosing the point of failure.
The apt-get install for curl definitely worked, and can be found in
/usr/lib/php5/20060613/curl.so
I think a lot of my confusion stems from not knowing which files go where, and what purpose they have. Any help would be appreciated, and please tell me if I need to provide more information.
edit:
The specific error I get is:
Exception: Facebook needs the CURL PHP extension.
from line
if (!function_exists('curl_init')) {
throw new Exception('Facebook needs the CURL PHP extension.');
}
Ubuntu: 9.10
PHP: 5.2.13
Loaded Configuration File: /etc/php5/apache2/php.ini
In general it's a bad idea to mix and match software from your distribution's package manager with stuff you've built yourself. The package manager will not know anything about the stuff you've built yourself and so can get confused.
Not only that but who's to say the stuff from the package manager is even binary compatible with the stuff you've built yourself? If you build it all yourself then at least you know it will all be compatible.
Sounds to me like you should uninstall the extensions and build them yourself. If you can't or don't want to do that then go back and install apache and friends through your package manager but I would recommend having patience and going for the former option.
Answer of Questions
What version of Ubuntu?
What version of PHP?
How is Apache and PHP set up?
What ini files does phpinfo() say is parsed? (should be near the top)
Perhaps apt failed to properly modify your php.ini file to load the curl extension?
Check out your php.ini and see if you have line like:
extension=curl.so
or maybe:
extension=/usr/lib/php5/20060613/curl.so
To check if php-curl is installed please follow these steps:
Create a file in your web server (in Ubuntu it would be in /var/www folder), name it info.php
Open that file and type this command:
<?php phpinfo(); ?>
Save that file
Open your favorite browser and open that file (ex: http://localhost/info.php)
Now you will see the Information about your PHP installation
Search for Curl, and if you cannot find it, it mean your php doesn’t have curl installed.
To install php-curl please follow these steps:
Open your terminal and type this command:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
After it finish open php.ini file (mine is at /etc/php5/apache2/php.ini ) and add this command: extension=curl.so
Save the file and restart apache with this command:
/etc/init.d/apache2 restart
Check the PHP information page again, you will find PHP-CURL installed
That’s it
Source: http://www.ivankristianto.com/os/ubuntu/howto-install-curl-in-php-apache/379/