【问题标题】:running my url instead of localhost using wampserver使用 wampserver 运行我的 url 而不是 localhost
【发布时间】:2014-09-13 15:43:27
【问题描述】:

这是我进行 REST API 调用的方式,我的网址在下面的 $url 中。我在 WAMP 服务器上运行它,基本上我已经保存了这个 php(test.php) 文件 www 文件夹,当我执行 url (localhost//test.php) 时,我收到 500 Internal Server 错误。我基本上想在我运行 URL($url) 时 运行 PHP 脚本。我应该如何克服这个问题?

<?php 
    $method = "POST";
    $accessKey = "myaccesskey";
    $secretKey = "mysecretkey";
    date_default_timezone_set("UTC");
    $timeString = date("D, d M Y H:m:s", time()) . ' GMT'; 
    $url = "http://myurl.com";
    $signature = GenerateSignature($secretKey, $method, $timeString);
    $authorization = $accessKey . ":" . $signature;
    $ListDEsc = "test new description";
    $data = "ListDEsc=" . $ListDEsc;
    var_dump(CallAPI($method, $url, $timeString, $authorization, $data));  

    function CallAPI($method, $url, $timeString, $authorization, $data = false)
    {
        $curl = curl_init();

        switch ($method)
        {
            case "POST":
                curl_setopt($curl, CURLOPT_POST, 1);

                if ($data)
                    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                break;
            case "PUT":
                curl_setopt($curl, CURLOPT_PUT, 1);
                break;
            default:
                if ($data)
                    $url = sprintf("%s?%s", $url, http_build_query($data));
        }

        $accept = 'application/json';

        an so on...

following post 一开始看起来很有希望,但他们的目标与我的不同。

错误日志:

在 C:\wamp\logs 中

我看到两个新创建的文件apache_errorphp_error

php_error 里面我有以下内容:

[22-Jul-2014 16:40:53 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_ldap.dll' - The specified module could not be found.

 in Unknown on line 0   

apache_error里面我有以下内容:

[Tue Jul 22 09:40:44.898375 2014] [mpm_winnt:notice] [pid 7672:tid 404] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations
[Tue Jul 22 09:40:44.959381 2014] [mpm_winnt:notice] [pid 7672:tid 404] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13
[Tue Jul 22 09:40:44.959381 2014] [core:notice] [pid 7672:tid 404] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Tue Jul 22 09:40:45.031389 2014] [mpm_winnt:notice] [pid 7672:tid 404] AH00418: Parent: Created child process 7148
[Tue Jul 22 09:40:54.412327 2014] [mpm_winnt:notice] [pid 7148:tid 320] AH00354: Child: Starting 64 worker threads.

浏览器错误如下:

string '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<title>500 - Internal server error.</title>

<style type="text/css">

<!--

body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}

fieldset{padding:0 15px 10px 15px;} 

h1{font-size:2.4em;margin:0;color:#FFF;}

h2{font-size:1.7'... (length=2007)

测试完成以查看 Curl 的工作情况

运行以下脚本:

<?php
  $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,'http://www.google.com');
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);
  if (empty($buffer)){
      print "Nothing returned from url.<p>";
  }
  else{
      print $buffer;
  }
?>

Source of above Script: 并且我已成功定向到 google.com 网页。

【问题讨论】:

  • 您的错误日志中有什么内容吗?
  • @Stefan 我在哪里可以查看我的错误日志?
  • @Stefan 我用错误日志更新了我的问题。请看。
  • 看起来您缺少 ldap 模块。如果你没有使用这个模块,你应该从相关的php.ini 文件中删除它的引用。

标签: php wampserver


【解决方案1】:

为确保您在 Apache/bin 文件夹中生成了所有正确的 SYMLINK,请执行以下操作。

使用 wampmanager 菜单单击 Apache 版本号以强制 Wampmanager 重做 SYMLINK 生成。

cURL 使用 libeay32.dll 和 ssleay32.dll,可能这两个库的 SYMLINKS 尚未创建。

wampmanager -> Apache -> Version -> Apache -> 2.4.9

【讨论】:

  • 我做了你提到的,但仍然得到同样的错误。顺便说一句,如果您提到的内容有问题,那么我的测试代码将无法正常工作。我说的对吗?
猜你喜欢
  • 2020-03-24
  • 1970-01-01
  • 1970-01-01
  • 2015-10-11
  • 2022-06-30
  • 2015-06-09
  • 2014-11-22
  • 1970-01-01
  • 2019-06-02
相关资源
最近更新 更多