Check to see if cURL is installed locally?

后端 未结 5 1169
难免孤独
难免孤独 2020-12-29 18:13

How do I check if cURL is installed on my local server instance?

Does it matter what type of server I\'m running to check it?

Is

5条回答
  •  一整个雨季
    2020-12-29 18:44

    cURL is disabled for most hosting control panels for security reasons, but it's required for a lot of php applications. It's not unusual for a client to request it. Since the risk of enabling cURL is minimal, you are probably better off enabling it than losing a customer. It's simply a utility that helps php scripts fetch things using standard Internet URLs.

    To enable cURL, you will remove curl_exec from the "disabled list" in the control panel php advanced settings. You will also find a disabled list in the various php.ini files; look in /etc/php.ini and other paths that might exist for your control panel. You will need to restart Apache to make the change take effect.

    service httpd restart

    To confirm whether cURL is enabled or disabled, create a file somewhere in your system and paste the following contents.

    ';
    var_dump(curl_version());
    echo '
    '; ?>

    Save the file as testcurl.php and then run it as a php script.

    php testcurl.php

    If cURL is disabled you will see this error.

    Fatal error: Call to undefined function curl_version() in testcurl.php on line 2

    If cURL is enabled you will see a long list of attributes, like this.

    array(9) {
    ["version_number"]=>
    int(461570)
    ["age"]=>
    int(1)
    ["features"]=>
    int(540)
    ["ssl_version_number"]=>
    int(9465919)
    ["version"]=>
    string(6) "7.11.2"
    ["host"]=>
    string(13) "i386-pc-win32"
    ["ssl_version"]=>
    string(15) " OpenSSL/0.9.7c"
    ["libz_version"]=>
    string(5) "1.1.4"
    ["protocols"]=>
    array(9) {
    [0]=>
    string(3) "ftp"
    [1]=>
    string(6) "gopher"
    [2]=>
    string(6) "telnet"
    [3]=>
    string(4) "dict"
    [4]=>
    string(4) "ldap"
    [5]=>
    string(4) "http"
    [6]=>
    string(4) "file"
    [7]=>
    string(5) "https"
    [8]=>
    string(4) "ftps"
    }
    }
    

提交回复
热议问题