卷曲问题。 PHP 脚本未在调用时运行
我正在寻找任何帮助调试当我 CURL 包含脚本的页面时可能阻止我的 php 代码运行的问题。
我从一个 PHP 脚本进行此调用:
$ch = curl_init($this->curl_address . $querystring);
$response = curl_exec($ch);
curl_close($ch);
到此脚本:(该脚本实际上做了一些事情,但它没有运行,所以我将其分解为这样,以便我有证据表明它没有运行,这就是目前在那里,并且日志中没有输出)
error_log("got here");
在我的测试服务器(Mac)上,CURL 脚本运行(我在日志中得到输出),但在我的生产服务器上它失败了。在这两种情况下,服务器上的一个脚本正在调用另一个脚本。
生产服务器是运行(我相信)CentOS 的 Linux VPS。
我不知道应该在生产服务器上寻找哪些问题。任何帮助表示赞赏。
谢谢。
I'm looking for any help debugging what could be preventing my php code from running when I CURL the page containing the script.
I am making this call from one PHP script:
$ch = curl_init($this->curl_address . $querystring);
$response = curl_exec($ch);
curl_close($ch);
To this script: (the script actually does stuff, but it wasn't running, so I broke it down to this so that I would have evidence that it does not run, this is what is currently there, and there is no output in the log)
error_log("got here");
On my test server (a Mac), the CURL'd script runs (I get output in the log), but on my production server it fails. In both cases one script on the server is calling another.
The production server is a Linux VPS running (I believe) CentOS.
I don't know what issues I should be looking for on the production server. Any help is appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在服务器托管的脚本中,使用
function_exists('curl_init');
检查是否安装了 cURL。如果该函数存在,则该函数将返回布尔值true,否则返回false。如果返回false,则必须在服务器中安装cURL。
如果您需要有关 PHP 设置的详细信息,您还可以使用
phpinfo();
调用。In your script hosted in the server, use a
function_exists('curl_init');
to check whether cURL is installed or not. This function will return a boolean true if the function exists, false otherwise.If it returns false, you have to install cURL in the server.
You can also use a
phpinfo();
call, if you want detailed information about your PHP setup.当我终于弄清楚问题时,我本打算在周末更新这个问题。生产服务器通过 HTTPS 提供服务,而测试服务器则不然。我遇到的问题是因为服务器没有通过 cURL 进行身份验证。
I meant to update this question over the weekend when I finally figured out the problem. The production server was serving over HTTPS, while the test server was not. The issue I was having was because the server wasn't authenticating over cURL.