简体   繁体   中英

A 500 Internal Server Error while running Google site search

This is a first time we are using GSS and applying in our application.

If we search a query in GSS we are getting good result depending upon the websites we have added to be searched from. But if we give GSS around a hundred queries one by one in a for loop, like,

   for ($i = 0, $count = count($arr1); $i < $count; $i++) 
   {
   print $arr1[$i]."\r\n\r\n";
  sleep(5);

  $in = $arr1[$i];
  $in = str_replace(' ','+',$in); // space is a +
 //google site search start here

$result = httpGet("https://www.google.com/cse?cx=003255331468891731323:xyxyxyxyxyyx&client=google-csbe&output=xml_no_dtd&q='$in'");

echo $result;
}

Here we have a long string of few pages which we have broken it into small arrays of say 30 words each. These array we have passed in a FOR loop, to get the result (various links) , we have printed the result with echo. We have also applied Sleep of 5 sec so that server gets time to get the result and print it , wait for 5 seconds before searching another query.

But when we are running this for loop, we are not getting result , rather our application hangs, and gives us the result as below:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@checkforplag.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

error screenshot

Kindly suggest what all do we need to do to apply GSS completely in our application.

Thank You!

I got solution for that by sending my php script in background process, and for that i used shell_exec.

This is the code i used:

$status = shell_exec("nohup /usr/bin/php test.php > /dev/null 2>&1 &");

And now i am not getting this kind of error even i am running a large file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM