PHP5.6 Unable to load Curl problem resolution

Source: Internet
Author: User
Tags phpinfo apache log
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

    1. Find the php.ini file path with phpinfo ()
    2. EXTENSION_DIR is configured correctly
    3. 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:

    1. The directory from which the application loaded.
    2. The Windows\System32 directory.
    3. The Windows\System directory.
    4. The Windows directory.
    5. The current directory.
    6. 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!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.