Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

Curl Calls are not working on Apache/PHP

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...