【发布时间】:2014-02-18 19:43:55
【问题描述】:
我正在开发一个使用 CURL PHP 的项目,但我无法安装 curl 扩展,因为我不是“Nitrous.io”框的 root 用户。
还有另一种在 Nitrous.io PHP Box 中安装 CURL PHP 的方法吗?
提前致谢!
【问题讨论】:
-
你想用 CURL 实现什么?可能有其他方法可以做到这一点,而不涉及 CURL
我正在开发一个使用 CURL PHP 的项目,但我无法安装 curl 扩展,因为我不是“Nitrous.io”框的 root 用户。
还有另一种在 Nitrous.io PHP Box 中安装 CURL PHP 的方法吗?
提前致谢!
【问题讨论】:
只需在 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.
我不熟悉 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);
}
【讨论】: