【问题标题】:use curl in php nitrous在 php nitrous 中使用 curl
【发布时间】:2014-02-18 19:43:55
【问题描述】:

我正在开发一个使用 CURL PHP 的项目,但我无法安装 curl 扩展,因为我不是“Nitrous.io”框的 root 用户。

还有另一种在 Nitrous.io PHP Box 中安装 CURL PHP 的方法吗?

提前致谢!

【问题讨论】:

  • 你想用 CURL 实现什么?可能有其他方法可以做到这一点,而不涉及 CURL

标签: php curl io nitrousio


【解决方案1】:

只需在 nitrous.io 盒子上重新安装 php5 包

$ parts update
$ parts install php5
$ php -m | grep curl
curl 
$ php -r 'echo curl_version()["version"] . PHP_EOL;'
7.22.0

【讨论】:

  • 运行parts install php5后,可能还需要重启Apache2。 parts stop apache2 , parts start apache2.
【解决方案2】:

我不熟悉 Nitrious.io,但如果您无法为您的项目访问/安装 curl,您将不得不直接联系 Nitrious 以了解如何使用 curl。

另外,您也许可以使用fsocketopen 来解决您的问题。示例:

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)
\n";
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}

【讨论】:

    猜你喜欢
    • 2015-10-31
    • 1970-01-01
    • 2017-01-23
    • 2011-04-05
    • 1970-01-01
    • 2010-10-26
    • 2014-11-25
    • 2011-04-20
    • 2016-09-08
    相关资源
    最近更新 更多