How to install PHP curl in linux ubuntu?

Member

by samara , in category: PHP General , 8 months ago

How to install PHP curl in linux ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , 3 months ago

@samara 

To install PHP curl in Ubuntu, follow these steps:

  1. First, update the package manager cache:
1
sudo apt update


  1. Then, install the PHP curl extension by running the following command:
1
sudo apt install php-curl


  1. Once the installation is complete, you'll need to restart your web server for the changes to take effect. For example, if you're using Apache, you can restart it using the following command:
1
sudo service apache2 restart


That's it! You should now have PHP curl installed on your Ubuntu system. To verify that the extension was installed correctly, you can create a PHP file with the following content:

1
2
3
4
5
6
<?php
if (function_exists('curl_version')) {
    echo "cURL is installed on this server";
} else {
    echo "cURL is not installed on this server";
}


Save the file as test.php and place it in your web server's document root. Then, open the file in a web browser by visiting http://localhost/test.php. If cURL is installed, you should see the message "cURL is installed on this server". If you see the message "cURL is not installed on this server", it means that the extension is not installed or not properly configured.