2013-07-23 4 views
0

저는 apache-tomcat을 사용하고 있습니다. 내 솔러는 내 로컬 호스트에서 잘 작동합니다. 이제 온라인에 넣고 싶습니다. 아파치 - 톰캣에서, 내 bin 폴더에 내 솔러 디렉터를 넣었습니다.하지만 온라인으로, 나는 빈 폴더가 없습니다. 아무도 구성 방법을 말해 줄 수 있습니까? 내 웹 호스트의 solr dir.thanks in advance내 웹에서 solr을 구성하는 방법은 무엇입니까?

답변

2

먼저 인증을 요구하여 전체 tomcat web admin gui를 보호합니다. 첫째,

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name> 
     Solr authenticated application 
     </web-resource-name> 

     <url-pattern>/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>POST</http-method> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>solrUsers</role-name> 
    </auth-constraint> 
    </security-constraint> 
    <login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>Basic Authentication</realm-name> 
    </login-config> 
    <security-role> 
    <description>solr users</description> 
    </security-role> 

/etc/tomcat6/web.xml 파일에 보안 제약 조건을 추가 /etc/tomcat6/tomcat-users.xml

<tomcat-users> 
    <role rolename="admin"/> 
    <role rolename="manager"/> 
    <role rolename="proxyUsers"/> 
    <user username="jorno" password="XXXXX" roles="admin,manager,proxyUsers"/> 
    <user username="proxyUser" password="XXXXXX" roles="proxyUsers"/> 
</tomcat-users> 

에서 새 사용자를 만들 바람둥이를 다시 시작하는 것을 잊지 마십시오

/etc/init.d/tomcat6 restart 

tomcat solr 응용 프로그램 웹 GUI를 방문하여 인증이 작동하는지 확인하십시오.

이제 실제 프록시를 apache로 만듭니다. 먼저 간단한 사이트를 만듭니다. PHP가 필요합니다. 다음의 가상 호스트 예는 트릭을 수행합니다. 재 작성을 확인하십시오.

q.example.com - SOLR 검색 엔진 프록시

<VirtualHost *> 
     ServerAdmin [email protected] 
     DocumentRoot /var/www/q.example.com 
     ServerName q.example.com 
     ServerAlias solr.example.com 

     AddDefaultCharset UTF-8 

     ErrorLog /var/log/apache2/error.log 

     # Possible values include: debug, info, notice, warn, error, crit, 
     # alert, emerg. 
     LogLevel warn 

     CustomLog /var/log/apache2/access.log combined 
     ServerSignature On 

     # REWRITES 
     RewriteEngine on 
     # Debug: 
     # RewriteLog /tmp/rwlog 
     # RewriteLogLevel 9 

     RewriteRule ^/([^/]+)/?     /index.php     [NC,L] 

</VirtualHost> 

이제 사이트의 루트에 index.php 파일을 만들 아파치에게

/etc/init.d/apache2 reload 

를 다시로드해야합니다. 색인을 얼마나 자주 업데이트하는지에 따라 사용자가 프록시 내용을 캐시하도록 할 수 있습니다. 나는 여기 5 분을 정했다.

<?php 

// Avvoid too long client cache 
// calc an offset of 5 minutes 
$offset = 60 * 5; 
// calc the string in GMT not localtime and add the offset 
$expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; 
//output the HTTP header 
Header($expire); 

// Write the result from solr 
Echo file_get_contents('http://proxyUser:[password]@127.0.0.1:8080/solr/select?'.$_SERVER["QUERY_STRING"]); 

?> 

꽤 많이 있습니다. 이제 이렇게

같은 프록시를 테스트 할 수 있습니다

http://q.example.com/select?q=퍼센트의 3A & 들여 쓰기 =

관련 문제