Call to undefined function curl_init() even it is enabled in php7
I’ve just installed php7 to my Ubuntu. At first, there was no problem, my web site was working. But suddenly, it started to return Call to undefined function curl_init() error. Now, my pages contain curl codes do not work.
In phpinfo(), it looks Curl is enabled. There were similar questions but none of them handled it in php7. I thought it should be something different than others.
in terminal, it returns
10 Answers 10
I’ve had similar problem with curl after upgrade to XX (16.04). After reinstalling curl with:
And server restart
everything went back to normal 🙂
Assumption
You’ve installed the version of the module for the PHP version you are using, and yet the problem is not going away.
There could be multiple versions of PHP installed on your system and Apache is not using the version you are expecting it to use.
How do you know which version of PHP Apache is using?
To know this, the key idea is to learn the ROOT directory of your Apache’s configuration files. In the command line, you can type:
In my case, my Apache’s ROOT configuration directory is shown in the
Now that I know the location of the configs that Apache is using, I can now accurately determine the version of PHP it is using by examining the «mods-enabled» directory located inside the «/etc/apache2» directory.
At this point, I now know for certain that Apache is using the ‘php5’ version of PHP installed on my system, whatever that may be.
Then I tried to reproduce the error above using this version of PHP (i.e., ‘php5’ ) by running the command below:
The version of PHP that I expected my Apache was using is «php5.6» and running the same command above with this version did not produce the said error.
Solution
To solve this problem, you either install the version of the module that corresponds to the PHP version that Apache is using (in my example php5.0-curl) or you may change the version of PHP that is being used in Apache to the version you want.
How do I tell Apache which version of PHP to use?
You can accomplish this using the a2enmod/a2dismod cli commands of Apache2.
Firstly, I disable the PHP module that is currently active on my server (i.e., «php5» ):
Then I enabled the php module for the version of PHP that I want my Apache to use:
Then I restart Apache
After I refreshed the offending page on my website, the error is now gone.
Fatal error: Call to undefined function curl_init() using Batch File
I have a PHP that downloads files from backend. I am using WAMP in Windows 7 and it works perfectly when done through the browser.
Now I have created a batch file to execute the php and it shows:
Fatal error: Call to undefined function curl_init()
Not sure why something that could work over in browser is not working in batch file. Below is my code for the batch file:
Any idea what’s the issue?
4 Answers 4
uncomment the following on your php.ini
and restart webserver. This might be due to curl disabled in your php.
When you use wamp, xamp or other all-in-one server, it uses an overrided php.ini located into bin/conf/ instead where original is.
You need copy from these or edit the ini located at php.exe folder.
If you cant access it (shared server, etc), you can create a custom php.ini file into script folder, and put needed instructions:
When using through browser it is using WAMP and the PHP ini is from C:\wamp\bin\php\php5.4.3
But I have set my php directory to C:\php-5.4.9 in environmental variables, thus when using windows batch it is calling php from that directory and there was no php.ini file there.
I copied the PHP ini file from wamp to php folder and now it is working.
Apparently I have installed php and then wamp, thus there is a overlap which has caused confusion.
1) sudo apt-get install php5-curl
Not the answer you’re looking for? Browse other questions tagged php curl or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.16.40224
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Call to undefined function curl_init() in WAMP server 3
I have been digging in StackOverflow for hours now but I still didn’t manage to resolve this 🙁
I want to do a POST request with Curl to get an Auth token, but even though I:
Can someone please help me with this issue?
2 Answers 2
Enable php_curl.dll extension, seems like it’s disabled. You can verify it by using
or directly access the php.ini to check if it’ disabled.
Save the file and restart the server.
1) Close WAMP (if running)
2) Navigate to WAMP\bin\php(your version of php)\
4) Search for curl, uncomment extension=php_curl.dll
5) Navigate to WAMP\bin\Apache(your version of apache)\bin\
7) Search for curl, uncomment extension=php_curl.dll
Not the answer you’re looking for? Browse other questions tagged php curl wamp or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.16.40224
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
curl_init() function not working
Hi I tries PHP Post Request inside a POST Request thinking it might be useful to me and my code is given below
form the index.php file and index2.php is another file in the same directory and when i open the page i get the following error in my error.log file
What i want to do is I have a reservation form that send post request and then i want to process post values and send again post request to paypal
23 Answers 23
You need to install CURL support for php.
In Ubuntu you can install it via
If you’re using apt-get then you won’t need to edit any PHP configuration, but you will need to restart your Apache.
If you’re still getting issues, then try and use phpinfo() to make sure that CURL is listed as installed. (If it isn’t, then you may need to open another question, asking why your packages aren’t installing.)
There is an installation manual in the PHP CURL documentation.
$ sudo apt-get install php5_curl Reading package lists. Done Building dependency tree Reading state information. Done E: Couldn’t find package php5_curl
For Windows, if anybody is interested, uncomment the following line (by removing the 😉 from php.ini
Restart apache server.
I got it working in ubuntu 16.04 by following steps.My php version was 7.0
sudo service apache2 restart
For Ubuntu: add extension=php_curl.so to php.ini to enable, if necessary. Then sudo service apache2 restart
The thumbprint will match all three of these conditions:
To fix this bug, I did:
In my case, in Xubuntu, I had to install libcurl3 libcurl3-dev libraries. With this command everything worked:
(remove the ; at the end of the line)
Add this to Apache/conf/httpd.conf (libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder)
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the php-curl package, and yet Apache is still giving you the same error.
I got this error using PHP7 / Apache 2.4 on a windows platform. curl_init worked from CLI but not with Apache 2.4. I resolved it by adding LoadFile directives for libeay32.dll and ssleay32.dll:
This answer is for https request:
Curl doesn’t have built-in root certificates (like most modern browser do). You need to explicitly point it to a cacert.pem file:
Without this, curl cannot verify the certificate sent back via ssl. This same root certificate file can be used every time you use SSL in curl.
This was after a system upgrade to next version of Ubuntu. All the other answers I found were stale, due to a bad cert apparently on the PPA most of them pointed out, but would probably not have worked anyway. The real issue was disabling the old versions of php, apparently.
Found the solution here:
(Trying to get Curl working via PHP and Apache on Windows. )
I kept getting an error saying: Call to undefined function ‘curl_init()’
I made sure I had enabled curl with this line in my php.ini file: extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this: extension_dir = «ext»
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I’d post in case it helps someone else.
I running litespeed 5.1.11 on my Centos 6.8 VPS (PHP 5.6.29). I use cUrl in my php code. When I run my code with browsing as a web page every thing work fine, but when I run with command it gave me error:
Fatal error: Call to undefined function curl_init()
How can I fix it?
I Compile my php with this configure parameters:
‘./configure’ ‘—prefix=/usr/local/lsws/lsphp5’ ‘—disable-fileinfo’ ‘—with-bz2’ ‘—enable-zip’ ‘—with-curl’ ‘—with-mysql’ ‘—with-mysql-sock’ ‘—with-sqlite’ ‘—with-tidy’ ‘—with-xpm-dir’ ‘—enable-pdo’ ‘—with-pdo-sqlite’ ‘—with-pdo-mysql’ ‘—enable-bcmath’ ‘—enable-calendar’ ‘—enable-ftp’ ‘—enable-gd-native-ttf’ ‘—enable-libxml’ ‘—enable-soap’ ‘—with-gettext’ ‘—with-jpeg-dir=/usr’ ‘—with-kerberos’ ‘—with-mcrypt’ ‘—with-mysqli’ ‘—with-openssl’ ‘—with-pic’ ‘—with-png-dir’ ‘—with-zlib’ ‘—with-pcre-regex’ ‘—with-gd’ ‘—enable-shmop’ ‘—enable-track-vars’ ‘—enable-sockets’ ‘—enable-sysvsem’ ‘—enable-sysvshm’ ‘—enable-magic-quotes’ ‘—enable-mbstring’ ‘—with-iconv’ ‘—enable-json’ ‘—with-litespeed’
And cUrl section in phpinfo:
2 Answers 2
After you compiled your PHP, you should get both lsphp and php binaries. If the prefix was /usr/local/lsws/lsphp5, Your compiled binaries should be in /usr/local/lsws/lsphp5/bin/, then for CLI, try php with your code.
/usr/local/bin/lsphp or /usr/local/bin/php does not look like the one your compiled since they are not under prefix folder.
Also, I don’t know if you have any particular reason to compile PHP by yourself since most of the people would just use RPM packages either from LiteSpeed repository or Remi repository. Installation is much easier and it should get your right.
Now I compile my php with this Configure Parameters:













