How to Install curl for PHP in Ubuntu

How to Install curl for PHP in Ubuntu

In this tutorial I will show you, how to enable and disable PHP curl module with Apache on Ubuntu. So, how to Install curl for PHP in Ubuntu?

Let’s install Apache curl module along with Apache 2 webserver and PHP.

# apt install libapache2-mod-php php-curl

Restart the Apache webserver:

# service apache2 restart

Check for curl module state

Insert the following lines into a new PHP script eg. curl-check.php within /var/www/html/ directory:

<?php
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' . "\xA" : 'Disabled' . "\xA";
?>

Make the script executable and use curl command to render the output of curl-check.php php code:

# chmod +x /var/www/html/curl-check.php
# curl localhost/curl-check.php
Curl: Enabled

Disable PHP curl module

To disable curl php module execute:

# phpdismod curl
# service apache2 restart
# curl localhost/curl-check.php
Curl: Disabled

Enable PHP curl module

To enable curl php module execute:

# phpenmod curl
# service apache2 restart
# curl localhost/curl-check.php
Curl: Enabled
 
Enjoyed this video?
How to Install curl for PHP in Ubuntu
"No Thanks. Please Close This Box!"