开发者

Solr-php-client issue

开发者 https://www.devze.com 2023-01-23 21:32 出处:网络
I am trying to run a script which can access a solr index using solr-php-client. THe script stops inside the ping function of Apache_Solr_Service class.

I am trying to run a script which can access a solr index using solr-php-client. THe script stops inside the ping function of Apache_Solr_Service class.

Then I tried to do this:

echo file_get_contents('http://localhost:8983/solr/admin/ping');

and got nothing --开发者_如何学Python blank page. BUT string http://localhost:8983/solr/admin/ping works as it should throw browsers address bar.

Can anybody suggest something on this?

Additional information: apache 2.2.3, CentOS 5.5, php 5.1.6, Solr 1.4.1

Thanks


Either, simply, just add a trailing forward slash after your url like this:

echo file_get_contents('http://localhost:8983/solr/admin/ping/');

Or just make sure you're not running in multicore mode. In which case you'd need to specify the name of your core before the admin like this

echo file_get_contents('http://localhost:8983/solr/CORE_NAME/admin/ping/');

First option should work for you though.

Also be aware where you host your code. It should be on that "localhost", otherwise make solr listed to a public IP and access that IP with php-solr-client.


Try

echo file_get_contents('http://127.0.0.1:8983/solr/admin/ping');

Okay, try:

<?php

  $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,'http://localhost:8983/solr/admin/ping');
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);

  echo $buffer;

?>


I found the solution:

semanage port -a -t http_port_t -p tcp 8983

Check this: http://wiki.centos.org/HowTos/SELinux -- see 5.4. Allowing Access to a Port section

Thanks for your help!

0

精彩评论

暂无评论...
验证码 换一张
取 消