Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My curl calls are not being enabled on Apache/PHP. My PHP version is 5.6.3 (x32) and Apache is 2.4

I've already uncommented the line that enables curl in C:/PHP/php.ini:

extension=php_curl.dll

Also, I have made sure to include in my path variables both the PHP path and PHP ext path so that both ssleay32.dll and libeay32.dll as specified by the PHP documentation is enabled. Here is the path:

C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)ATI TechnologiesATI.ACECore-Static;C:Program FilesTortoiseSVNin;C:PHP;C:PHPext;C:Apache24in;C:xamppapachein;C:Ruby193in;C:xamppapachein"

However, I still get this error in the log after numerous restarts:

PHP Fatal error:  Call to undefined function curl_init() in C:\Apache24\htdocs\user\newapi\test.php on line 5, referer: http://localhost/newapi/
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
237 views
Welcome To Ask or Share your Answers For Others

1 Answer

I know it's obvious, but the first place to check is the PHP configuration, make sure that curl is NOT listed in either:

disable_functions=
disable_classes=

While checking php settings, make sure that you have (based on your path):

extension_dir="C:PHPext"

Verify (again) that C:PHPextphp_curl.dll actually exists and that it wasn't just copied from the XAMPP install.

After that, depending on how you launch Apache (as a service using the System account or as a user), you may need to check the user path in addition to the system path.

At one point in time, I'd found that I had multiple copies of ssleay32.dll and libeay32.dll that were being called BEFORE the PHP binaries causing a version conflict. I've included an example of the trouble I ran into below.

To see the full path being used (assuming Apache is being run from user space):

C:> echo %PATH%
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Filescurl;C:Program Filescurldlls;C:Webphp;C:Python27;

On this machine, these entries are from my user path and not the system path:

C:Program Filescurl;C:Program Filescurldlls;C:Webphp;C:Python27;

To check the location of installed files in the path:

C:> where ssleay32.dll
C:Program Filescurldllsssleay32.dll
C:Webphpssleay32.dll
C:> 

In this example, the included dlls for my builds of curl and php were far enough apart that they were incompatible with each other. PHP was trying to load curl's dlls, but failed. I don't have it installed so I can't check right now, but TortoiseSVN may include them.

It would probably also be worth verifying the permissions on the file:

C:> cacls c:Webphpssleay32.dll
C:Webphpssleay32.dll BUILTINAdministrators:(ID)F
                        NT AUTHORITYSYSTEM:(ID)F
                        BUILTINUsers:(ID)R
                        NT AUTHORITYAuthenticated Users:(ID)C

As a side note, copying files to %SystemDrive%WindowsSystem32 is a bad idea. It's basically just a hack to get whatever files into the system path (in a priority position) without having to explain to the user how to edit the path variables.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...