- 1. Enable the «curl» extension in php.ini
- 2. Add the path to the PHP file in the environment variable «PATH» Windows.
- 3. Restart the Apache service take into account changes
- 4. Test the curl extension through our example
- Enable php curl windows
- User Contributed Notes 21 notes
- How to enable cURL in PHP?
- How To Enable PHP cURL Extension?
- How to enable CURL via the php.ini file by cPanel
If you’ve ever tried to use the «curl» of PHP on Windows, you may have noticed that PHP you return an error stating that the «curl_init()» function (or another function curl) was not defined.
The reason is simple : this extension is not enabled by default in PHP.
1. Enable the «curl» extension in php.ini
First, to enable the «curl» extension to PHP, you have 2 options:
— Either you have WAMP :
In this case, you can activate it by clicking on the WAMP (left-click) and then going to «PHP -> PHP extensions». Then click «php_curl» to a «v» appears next.
— Either you installed PHP from the official website of the author :
In this case, you need to edit the «php.ini» file located in the root folder of PHP.
In this file, uncomment the following line by removing the «;» if present (or add it if it is not there) :
2. Add the path to the PHP file in the environment variable «PATH» Windows.
As stated on the official website of PHP curl module needs DLLs «libeay32.dll» and «ssleay32.dll» to work.
So PHP can find and use so you have 2 solutions :
— Either copy the folder C:\Windows\System32
— Either add the folder path in the PHP environment «PATH» variable of Windows. (Recommended)
To add, modify the variable by adding the path to the PHP file at the end of this variable, separating by ;
Note : If you don’t know how to change an environment variable, take a look at our tutorial : Change and / or display environment variables in Windows
3. Restart the Apache service take into account changes
To restart the Apache service is the web server running PHP as a module :
— Launch the «services.msc program
— Select «Apache» (named «wampapache» with WAMP) service
— Then click Restart (in the right column)
For more information on managing services in Windows, take a look at our tutorial : Managing Windows Services
4. Test the curl extension through our example
Here is a PHP script that will show you the Wikipedia page on curl.
Enable php curl windows
To use PHP’s cURL support you must also compile PHP —with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the include directory there should be a folder named curl which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the lib directory.
Note: Note to Win32 Users
In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll , or, as of OpenSSL 1.1 libcrypto-*.dll and libssl-*.dll , must be present in your PATH . Also libssh2.dll must be present in your PATH . You don’t need libcurl.dll from the cURL site.
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
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 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.
How To Enable PHP cURL Extension?
Are you looking for the multiple way to enable PHP cURL extension into your server? In this article, we’ll share some of way to enable PHP cURL extension.
To enable the PHP-cURL extension onWindows systems
- Open php.ini file located under php installation folder.
- Search for extension=php_curl.dll.
- Uncomment it by removing the semi-colon(;) in front of it.
- Restart the Apache Server.
To enable the PHP-cURL extension on Linux Ubuntu/Debian, you must first install it with the command:
sudo apt-get install php-curl
Or so for the old PHP5 version:
sudo apt-get install php5-curl
You can activate/deactivate the PHP module like this:
sudo phpenmod curl sudo phpdismod curl
Restart Apache2 to apply the changes:
sudo /etc/init.d/apache2 restart
Check if curl is activated:
How to enable CURL via the php.ini file by cPanel
Step 2: Navigate to the Files section and click the file manager icon.
Step 3: Navigate to the public_html directory and find the php.ini file.
Step 4: Select the php.ini file and right-click to edit button.
Step 5: You will appear a popup window and click on the Edit button and proceed.
Step 6: A new tab will appear in the browser and add the below code in your php.ini file
extension=php_curl.dll
Save the file, now you have successfully enabled the CURL extension.
I hope that this article will help you to How to enable PHP cURL extension.
If you have any query then please let me know in the comments section. If you think this post saved your time, please subscribe to our newsletter for regular updates.