简体   繁体   中英

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:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;C:\PHP;C:\PHP\ext;C:\Apache24\bin;C:\xampp\apache\bin;C:\Ruby193\bin;C:\xampp\apache\bin"

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/

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:\PHP\ext"

Verify (again) that C:\\PHP\\ext\\php_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:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\curl;C:\Program Files\curl\dlls;C:\Web\php;C:\Python27;

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

C:\Program Files\curl;C:\Program Files\curl\dlls;C:\Web\php;C:\Python27;

To check the location of installed files in the path:

C:\> where ssleay32.dll
C:\Program Files\curl\dlls\ssleay32.dll
C:\Web\php\ssleay32.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:\Web\php\ssleay32.dll
C:\Web\php\ssleay32.dll BUILTIN\Administrators:(ID)F
                        NT AUTHORITY\SYSTEM:(ID)F
                        BUILTIN\Users:(ID)R
                        NT AUTHORITY\Authenticated Users:(ID)C

As a side note, copying files to %SystemDrive%\\Windows\\System32 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM