2

I am aware that there are other questions with a similar title, such as the following:

curl_init() function not working

However I am still not able to get curl working on my localhost and on my server.

For this case, I will focus on the server, which is a Windows Server 2019.

The version of Apache is 2.4.46.

The version of PHP is 7.4.12.

In the php.ini file, I have the following uncommented:

extension=curl

In the extension folder, I can see the following file:

php_curl.dll

On the phpinfo.php page, I don't see that curl has been enabled, which is strange. The only place I see curl is in the module.authors section, and it looks like this:

cURL           |          Sterling Hughes

I have already restarted the services, but I am still getting the following error:

Fatal error: Uncaught Error: Call to undefined function curl_init() 

What am I doing wrong and how can I fix this?

Edit

I just added this piece of code:

echo "<pre>", print_r(get_loaded_extensions()), "</pre>";

And I get the following:

Array
(
[0] => Core
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => date
[5] => filter
[6] => hash
[7] => iconv
[8] => json
[9] => SPL
[10] => pcre
[11] => readline
[12] => Reflection
[13] => session
[14] => standard
[15] => mysqlnd
[16] => tokenizer
[17] => zip
[18] => zlib
[19] => libxml
[20] => dom
[21] => PDO
[22] => openssl
[23] => SimpleXML
[24] => xml
[25] => xmlreader
[26] => xmlwriter
[27] => apache2handler
[28] => mysqli
[29] => Phar
[30] => pdo_mysql
)
1

None of which are for curl.

12
  • cURL should already be enabled with PHP 7.x, not sure though, without any external dependency or INI hack. You can check by altering the PHP version to a different minor version. Also, off topic though, why would someone use Apache on a Windows Server while it comes with a built in web server IIS! Commented Jul 12, 2021 at 18:02
  • Do you have any other extensions loaded? On my Windows machines, the extensions folder listed in php.ini is always wrong and I need to manually uncomment that line so that it points to the correct location. Commented Jul 12, 2021 at 19:03
  • @ChrisHaas - Other extensions are indeed loaded. For example, PDO. No issues with the PDO extension. Commented Jul 12, 2021 at 19:07
  • @BrokenArrow - Regarding the off topic question, I don't really have an answer. All I can say is that we are doing a migration of servers, and a number of sites were already using Apache. We have another server that we use the IIS services (if that makes sense). Commented Jul 12, 2021 at 19:09
  • 1
    @JohnBeasley Completely makes sense :) Commented Jul 12, 2021 at 19:15

3 Answers 3

4

I was able to finally solve this issue by finding a file in my PHP root folder called libssh2.dll and copy/paste into the Apache bin folder. Once I did that, curl is now enabled, and I no longer get the error in question. I'm getting other errors, but that's for another question.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, glad it worked for me on my Windows! also thanks man
0

Had a similar problem. My PHP 8.2-curl was installed, but somewhere 8.3 was upgraded, and 8.3-curl didn't get installed.

It worked when I uninstalled 8.3 and 8.2 and reinstalled PHP from scratch.

Comments

0

Faced with the same problem with PHP 8.3.10 and Apache 2.4.62. Enabling the curl extension is not solve the problem. By adding this line to the end of Apache configuration (httpd.conf), I solved the problem:

LoadFile "${SRVROOT}/php/libssh2.dll"

or

LoadFile "<apache path>/php/libssh2.dll"

Only this file is needed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.