How to install PHP curl in linux ubuntu?

Member

by samara , in category: PHP General , 2 years ago

How to install PHP curl in linux ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by rollin , 2 years 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.

by cortez.connelly , a year ago

@samara 

To install PHP cURL extension in Ubuntu, follow these steps:

  1. Open the terminal on your Ubuntu system.
  2. Update the package list using the following command: sudo apt update
  3. Install the PHP curl extension by running the following command: sudo apt install php-curl
  4. After installation, restart the Apache web server using the following command: sudo systemctl restart apache2
  5. Verify the cURL extension is installed by creating a PHP info file. Create a file named info.php in your web server's document root (e.g., /var/www/html/) using the following command: sudo nano /var/www/html/info.php
  6. Add the following line to the info.php file, save, and exit:
  7. Now, access the info.php file in your web browser using the URL http://your-server-ip/info.php. Look for the cURL section in the PHP info page, which confirms that the PHP cURL extension is installed and enabled.


Note: These instructions assume that you have Apache as your web server and PHP is already installed on your Ubuntu system.