Php curl enable php ini

Enabling CURL in PHP (PHP.ini, WAMP, XAMPP, Ubuntu)

In this quick tip tutorial we’re looking at how to enable CURL in PHP. I’ve included a number of different options as it may be different depending on what your running.

For those that want a bit of background on what CURL is and can be used for continue reading. If you just want the answer click here!

What is CURL?

CURL is a library created by Daniel Stenberg that allows you to connect and communicate via a variety of different protocols such as HTTP, HTTPS, FTP, Telnet etc

I personally use cURL as an alternative to file_get_contents(URL) to get web content as it provides better performance and additional functionality and flexibility.

Why doesn’t CURL work on my computer?

By default CURL isn’t enabled in Apache and therefore trying to make a CURL call won’t work until you’ve enabled it.

CURL Error Message

If curl isnt running and your trying to run it In php you’ll more than likely be Seeing an error message like : “Fatal error: Call to undefined function curl_init()”

Right, now we’ve covered that lets get cURL working!

How to enable CURL in Apache

There are a few ways I found to go about enabling CURL in apache. The one you choose will depend on what OS your running and which flavour of Apache you’ve got.

Hopefully one of these should sort you out:

Option 1 : enable CURL via the php.inI

This is the main method on any windows install like WAMP, XAMPP etc

  1. Locate your PHP.ini file
    (normally located at in the bin folder of your apache install e.g.
  2. Open the PHP.ini in notepad
  3. Search or find the following : ‘;extension=php_curl.dll’
  4. Uncomment this by removing the semi-colon ‘;’ before it
  5. Save and Close PHP.ini
  6. Restart Apache

Location of php.ini - click to enlarge

Option 2: Enabling CURL in WAMP

  1. Left-click on the WAMP server icon in the bottom right of the screen
  2. PHP -> PHP Extensions -> php_curl

Option 3: enable CURL in Ubuntu

Run the following command:

How to Make sure CURL is enabled and running

Option 1: Use the phpinfo() command to output PHP’s configuration and look for curl support under the listed environment variable/modules

Option 2: Create and run a simple PHP script like the following:

Читайте также:  Html form true false

// reinitialize curl resource
$ch = curl_init();// set url
curl_setopt($ch, CURLOPT_URL, “domain.com”);

//return the as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// echo output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);

Option 3: On a unix machine type the following command:

If you have any questions leave them below. Don’t forget to share this if it was useful!

My name is Tom Jepson. I’m a Technical SEO freelancer with almost 20 years experience in Search Engine Optimisation. Proud Father, Python enthusiast, Self-confessed tech nerd, Ropey Guitarist and Photographer.

10 thoughts on “Enabling CURL in PHP (PHP.ini, WAMP, XAMPP, Ubuntu)”

hey buddy! we dont know each other but i have to call u buddy because with your help i cured a one day headache! my page works fine now! MILLION THANKS. Reply

I have been trying to fix this for the past 8 hours. Here is what I have done to try and fix the problem relating to curl. uninstalled and installed xampp. in the php.ini file, deleted the ;for the comment on the extension. restarted apache. ran a phpinfo() and curl is not listed at all anywhere. So, not sure what the next step is. Tried to find out if I have to downloaded curl separately but I would assume it is part of xampp. Any suggestions are help. Thanks, Grant Reply

Currently running a test site on localhost. I have deleted the ; in the php.ini file and restarted xampp and ran phpinfo(). Curl is not showing up anywhere in the list, whether disable or enabled. Am I missing a file or something. I uninstalled and then reinstalled xampp and it didn’t help either. Need help on this one. Thanks, Grant Reply

Hi Grant, are you definitely editing the right php.ini? Apparently in some versions of Xampp there are multiple versions of the php.ini file which could be your problem. On my installation, the main file is located in c:\xampp\php\php.ini but i’ve heard of other installs that have it in /apache/bin/php.ini FYI – you shouldn’t have to install the curl dll separately as it comes with Xampp. You might want to double check your extension folder though just to make sure its in there. c:\xampp\php\ext\php_curl.dll Let me know how you get on. All the best, Tom Reply

Источник

Php curl enable php ini

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:

Читайте также:  Adressbook of «YourMegaCompanyName»

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 🙂

Читайте также:  Html text border padding

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 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

  1. Open php.ini file located under php installation folder.
  2. Search for extension=php_curl.dll.
  3. Uncomment it by removing the semi-colon(;) in front of it.
  4. 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.

Источник

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