Curl is loaded
The Curl extension under PHP has recently been used in a project, but has encountered a problem that the curl function cannot perform while actually running, and the page error is:
Call to undefined function curl_init ();
Environment configuration:
- Windows 64bit
- Apache 2.4 (WIN32)
- PHP 5.6.21 TS
Follow the general steps to check
- Find the php.ini file path with phpinfo ()
- EXTENSION_DIR is configured correctly
- Extension=php_curl.dll is open
The results are normal, but the results of phpinfo () do not have a curl module
And then with the search, most of the solutions on the Web are:
- Put Libeay32.dll,ssleay32.dll into System32, restart Apache, and some said to put Php5ts.dll also put in, the closest is to put Libssh2.dll into/bin
- Consider whether the PHP version number and the Php_curl.dll version number are consistent
- You might want to use the Libcurl.dll library.
- Check Apache restart posture, not only with httpd-k restart, but also restart from system service
Finally, the friend gives an ultimate method: Kill the present environment, find an integrated environment to reload again!
This is also a way, but I do not want to re-install, how to do?
In addition, I found a strange phenomenon, I check the loaded module under command line, curl can be loaded, and can be executed. But with Phpinfo () is the display is not loaded.
Then let the dog check the phenomenon, but there is no useful information.
An accidental idea, went to see the Apache log and found a line:
PHP Warning: php startup:unable to load Dynamic Library ' C:\\server\\php\\ext\\php_curl.dll '-the operating system C Annot run%1.\r\n in Unknown on line 0
According to Apache's error log, it is possible to see that the operating system did not find the corresponding dynamic link library.
So put the dog, open a PHP Official document: PHP: Install-Manual, find the operating system cannot run%1.\r\n, find the title Mtudor at icefusion remove me DOT co uk ¶ A post that was posted 7 years ago in which he described a phenomenon almost consistent with the problem! , and gives a detailed analysis of this problem, the causes and solutions.
Which in the cause section, he wrote:
Cause-----This is caused by PHP picking up the wrong VERSIONS of Libeay.dll and Ssleay.dll, which were present in MULTIPL e locations on my computer.
When any application attempts-a DLL is file in Windows, the system searches for this file using the following order:
- The directory from which the application loaded.
- The Windows\System32 directory.
- The Windows\System directory.
- The Windows directory.
- The current directory.
- The directories that is listed in the PATH environment variable.
(http://msdn.microsoft.com/en-us/library/ms682586.aspx)
For PHP running under Apache, the application directory is \ Bin and not . PHP was finding out of DATE versions of Libeay.dll and Ssleay.dll in \ bin (probably installed when I enabled SSL support I n my Web server). Because of this, the latest versions in Windows\System32 were never reached.
He focuses on the sequence in which Windows systems look up dynamic link library files and notes the following:
For PHP running under Apache, the application directory is \ Bin and not .
This means that Apache may need to find Libeay32.dll,ssleay32.dll and Php_curl.dll files in its own environment, but we did not copy them from the PHP folder to Apache/bin. Instead, it was put into the windows/system32, and the egg.
After correcting, finally saw the familiar result. This also explains the phenomenon that I can perform curl_init () under command line, but I can't see it with the Phpinfo () function.
Summary: Logs are important!