Ubuntu install curl extension php

Ubuntu install curl extension php

Для использования cURL необходимо собрать PHP с опцией —with-curl[=DIR], где DIR — имя каталога, содержащего подкаталоги lib и include . Каталог include должен содержать подкаталог curl с файлами easy.h и curl.h . В каталоге lib должен быть файл libcurl.a .

Замечание: Замечание для пользователей Win32
Для работы с этим модулем в Windows файлы libeay32.dll и ssleay32.dll , либо, начиная с OpenSSL 1.1, libcrypto-*.dll и libssl-*.dll , должны существовать в системной переменной окружения PATH . Также libssh2.dll должен присутствовать в вашей переменной окружения PATH . Вам не требуется файл libcurl.dll с сайта cURL.

User Contributed Notes 21 notes

I already had Apache and PHP5 setup, but simply adding php5-curl and curl did *not* work. I also had to get libcurl3 and libcurl3-dev. The full command:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

You’ll know if it works because phpinfo() will get a new section with Curl info.

Upgrading to php 5.6.9 on Windows 7 x64 curl no longer is recognised. No errors on server start package just not available and didn’t show in phpinfo.php. deplister.exe was ok
I fixed coping the following list files from php folder (in my case D:\xampp\php)
libeay32.dll
libssh2.dll
ssleay32.dll
to c:\xampp\apache\bin (or your apache\bin path), restart apache and works fine, apache’s libraries were outdated

Читайте также:  Python строка русского алфавита

Beginning with version 1.1.0 OpenSSL did change their libary names!
libeay32.dll is now libcrypto-*.dll (e.g. libcrypto-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows)
ssleay32.dll is now libssl-*.dll (e.g. libssl-1_1-x64.dll for OpenSSL 1.1.x on 64bit windows)

You may be confused, as I was, by the instructions for installing cURL in php. The instruction «To use PHP’s cURL support you must also compile PHP —with-curl[=DIR]. » was murky to me, since I didn’t compile php when I installed it. I just copied all of the necessary files to the correct folders as described very clearly in the php manual.

I am using Windows XP and Apache with php 5.1.6. In this situation, and it may apply to php versions of 5.0 and later, all one needs to do is remove the «;» from the front of the directive extension=php_curl.dll. You should also check to make certain that libeay32.dll and ssleay32.dll are in your php directory with the other dll’s. This directory should already be in you path, so the instruction to put them in you path is not critical.

You can then run phpinfo() and you should see a heading for curl in the listing.

Succinctly, my installation of cURL consisted of removing the semi-colon in front of the ;extension=php_curl.dll line in php.ini, saving php.ini and restarting Apache. You may wish to try this if you are using php 5.0 and later and are having difficulty understanding the instructions on the cURL installation page at php.net

You dont need to copy files to use PHP CURL with Apache 2.4 — use the LoadFile directive in your apache config file instead:
LoadFile «C:/php7/libssh2.dll»
(that was all it took for me to get it work)

If you’re dense like I am, spare yourself the trouble on an Ubuntu system (probably Debian too) and.

$ sudo apt-get install php5-curl

Then feel dumb, but not as dumb as me.

If you are running on Windows with a Wampserver or alike preconfigured PHP, if you did everything that was advised (path is correct, dlls are in the System32 or the Wow64 folder, php_curl extension uncommented in the php.ini, rebooted your machine and restarted your services), and you still receive messages saying that curl is not installed :
— maybe you are running a command line script (and not a curl instruction within a web application). If yes, remember that there are 2 distinct php.ini configuration files : one for the php-cli commands (run php at command line) and one for the php instructions (run from a page in your www folder).
Wampserver’s menuitem «php.ini» only opens the webserver’s php.ini, not the php-cli one.
So it will be great to check your php-cli’s php.ini configuration file ! (you’ll find it in the php.exe’s installation folder)
You need to uncomment the extension php_curl in this php.ini file for the command lines to work with curl.
Also uncomment the php_openssl extention by the way (often used with curl).
I hope this fixed issue will help someone else 🙂

It is not necessary to always (re)compile PHP. For me it was sufficient to install php5-curl and restart Apache:

$ sudo apt-get install php5-curl
$ sudo /etc/init.d/apache2 restart

Источник

How To Install php-curl on Ubuntu 22.04

In this tutorial we learn how to install php-curl on Ubuntu 22.04.

What is php-curl

This package provides a CURL module for PHP.

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

This package is a dependency package, which depends on Debian’s default PHP version (currently 8.1).

There are three ways to install php-curl on Ubuntu 22.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install php-curl Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install php-curl using apt-get by running the following command:

sudo apt-get -y install php-curl 

Install php-curl Using apt

Update apt database with apt using the following command.

After updating apt database, We can install php-curl using apt by running the following command:

sudo apt -y install php-curl 

Install php-curl Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

After updating apt database, We can install php-curl using aptitude by running the following command:

sudo aptitude -y install php-curl 

How To Uninstall php-curl on Ubuntu 22.04

To uninstall only the php-curl package we can use the following command:

sudo apt-get remove php-curl 

Uninstall php-curl And Its Dependencies

To uninstall php-curl and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove php-curl 

Remove php-curl Configurations and Data

To remove php-curl configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge php-curl 

Remove php-curl configuration, data, and all of its dependencies

We can use the following command to remove php-curl configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge php-curl 

References

Summary

In this tutorial we learn how to install php-curl package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.

Источник

How To Install PHP CURL Extension In Ubuntu

In this article, we will focus on the process of installing the PHP cURL extension in Ubuntu. The PHP cURL extension provides an easy-to-use interface for making HTTP requests, sending and receiving data from remote servers, and working with various protocols such as HTTP, HTTPS, FTP, and more.

By installing this extension, you can empower your PHP applications with powerful networking capabilities.

In the following sections, we will provide you with a step-by-step guide on how to install the PHP cURL extension in Ubuntu. We will cover the necessary commands and configurations to ensure a successful installation.

So, let’s get started and learn how to install the PHP cURL extension on your Ubuntu system.

Open a terminal window and run the following command to update the package lists.

Once the package lists are updated, you can proceed to install the PHP cURL extension by running the following command.

sudo apt-get install php-curl

Run the following command to install php-curl for PHP 8.2.

sudo apt-get install php8.2-curl

Run the following command to install php-curl for PHP 8.1.

sudo apt-get install php8.1-curl

Run the following command to install php-curl for PHP 8.0.

sudo apt-get install php8.0-curl

Run the following command to install php-curl for PHP 7.4.

sudo apt-get install php7.4-curl

Run the following command to install php-curl for PHP 7.3.

sudo apt-get install php7.3-curl

After the installation is complete, you need to restart the PHP service for the changes to take effect. Run the following command to restart PHP.

sudo service apache2 restart

To ensure that php-curl is successfully installed. Run the following command to check.

You might also like:

  • Read Also: Laravel 8 cURL HTTP Request Example
  • Read Also: How To Install PHP XML Extension In Ubuntu
  • Read Also: How To Fix cURL Error 60 SSL Certificate Problem
  • Read Also: Skype Screen Sharing Not Working Ubuntu In 22.04

Источник

How to enable cURL in PHP?

Often, web applications require HTTP based UserID and Password authentication, cookies, and form uploads. Even, user authentication with Google or Facebook sign-in is done via HTTP. In these types of cases, we need to request a particular service server(Like Google’s) for user validation and authentication token on our server. The entire process takes place through the service server’s APIs. The cURL helps our web applications to interact/communicate with those APIs on the HTTP level.

cURL: It is a library created by Daniel Stenberg. The cURL stands for client URL. It allows us to connect with other URLs and use their responses in our code. The cURL is a way that can hit a URL from our code to get an html response from it. The cURL is also used in command lines or scripts for data transfer. cURL with respect to PHP is a library that lets us make HTTP requests in PHP. It’s easier to do GET/POST requests with curl_exec to receive responses from other servers for JSON format data response and to download files.

Required to “enable” cURL: The cURL, by default, is not enabled in Apache. If we try to run CURL programs without enabling CURL in Apache, the browser will throw an error.

Fatal error: Call to undefined function curl_init()

.
To avoid this, we need to enable the CURL extension in the Apache server with the following methods in different environments.

Enable CURL in Apache: Enabling CURL in Apache by configuring php.ini file.

  • Step 1: Locate PHP.ini file, it is mostly in the server’s root folder or public_html then open the PHP.ini in a text editor
  • Step 2: Search or find the ;extension=php_curl.dll with Ctrl+F and remove the semi-colon ‘;’ before it to activate it.
  • Step 3: Save and Close PHP.ini with Ctrl+S and restart Apache from terminal/CMD

Enabling cURL in WAMP: WAMP is a software stack available for Windows that bundle Apache, MySQL, and PHP together. It’s an installation pack for installing the three web technologies on the Windows environment together in a hassle-free GUI guided fashion.

  • Step 1: Left-click on the WAMP server icon in the bottom right of the screen.
  • Step 2: PHP -> PHP Extensions ->curl.

Enabling CURL in Ubuntu: Run the following command:

    This command installs the PHP CURL.

sudo apt-get install php5-curl
sudo service apache2 restart

Check if CURL is enabled or not: If we try to run a cURL PHP program without cURL being enabled, the browser will throw the following error.

Источник

Оцените статью