This tutorial will show you how to install cURL and check whether cURL is enabled or not in your web server. cURL is a command line tool for transferring the data from one server to another by accepting multiple types of request.
In another way, cURL (Transfer a URL) is a very lightweight command line tool which handles the HTTP request without sending explicit request from browser.
cURL supports multiple protocol like SMTP, SMTPS, HTTP, HTTPS etc. Most of the web applications are using cURL to handle their API request.
As per Wikipedia, cURL was released on 1997 and the name was httpget, then urlget and now it is cURL. It uses libcurl library which is threadsafe and available in mot of the popular language like C, PHP, JAVA, Python, etc. I have used curl in one of my script Login with Twitter OAuth API Using PHP
We already learn that most of the modern web servers already supports cURL and it is enabled by default. If not, then you can also install and enable it in any web servers.
Note: If you are using any shared web server like DreamHost, Bluehost, etc then you can contact to your service provider to enable it.
Now without wasting the time, we will see how to install and enable it in multiple distributions of operating system.
Once you type curl in your Ubuntu terminal and it says 'curl command not found', it means that cURL package is not installed in you Ubuntu.
So this is time to install it in your Ubuntu machine. Simply open the terminal and type the below command:
sudo apt update
sudo apt install curl
After completing the installation, you can verify whether it is installed or not by typing the below command in terminal
curl
It is pre-installed in the latest version of Fedora distribution. cURL is inbuilt from fedora 27 onward. If you still want to install curl for the older version of fedora then run the below command as a root user.
yum install curl
To install php-curl, you can run the below command after login as root.
dnf -y install php-curl
Verify your curl installation in Fedora
curl --verison
To install curl in OpenSUSE, please run the below command in the terminal
zypper install curl
Installing php-curl in PHP 7.0
apt-get install php-curl
Install php-curl in PHP 5.6
apt-get install php5.6-curl
Install php-curl in PHP 5.5
apt-get install php5.5-curl
Now you can verify your installation and check the installed version of curl by running the below command.
curl --verison
The installation of curl in windows machine is very simple. You can follow the below steps to enable it.
1. Open your computer C:\
drive and go to C:\wamp\bin\apache\Apache2.2.21\bin directory
.
2. Open php.ini
file from the above directory.
3. Enable php_curl.dll extension. This can be enabled by removing ';' extension=php_curl.dll
;extension=php_curl.dll
to
extension=php_curl.dll
4. After enabling this extension, you need to restart your server.
To check whether CURL is enable or available on your web server or not. Please make a .php
file and write the below code and you can easily check from available extensions.
<?php
if (in_array ('curl', get_loaded_extensions())) {
echo "CURL is available on your web server";
} else {
echo "CURL is not available on your web server";
}
?>
This is a simple method to check whether CURL is enable or not. The another way to check it, Just run phpinfo();
function in your web browser if CURL is enable then a block of CURL will display in your screen and will look like below screenshot: