HTML2011. 5. 16. 20:38

<?

$img_full_name = "<img src='/data/review/_12961712360.jpg' name=target_resize_image_review[]><br>
<img src='/data/review/_12961709040.jpg' name=target_resize_image_review[] >
 <br />dhahaerhgeargreagre";
 
 
 
if($img_full_name != "")

 preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", stripslashes($img_full_name), $out5);   
  
 $test = "";
 for($i=0; $i< sizeof($out5[1]); $i++)
 { 
  eregi("[^= '/]*\.(gif|jpg|bmp)", $out5[1][$i], $regText2);  
  $test .= $regText2[0] .",";
 }
 $test = rtrim($test, ",");
 
 echo "<br>";    
 echo $test;
 echo "<br>"; 

}
 
 
 
 dir;

 
?>



<Sphinx 설치방법>
 - http://www.sphinxsearch.com/docs/current.html

 

[참고]
- mysql 설정확인방법 : # mysql_config --libs

 

[Installing Sphinx on Linux]

1. Extract everything from the distribution tarball (haven't you already?) and go to the sphinx subdirectory:

$ tar xzvf sphinx-0.9.8.1.tar.gz
$ cd sphinx   (설치경로: # cd sphinx-0.9.8.1)

2. Run the configuration program:

# ./configure --prefix=/usr/local/sphinx --with-mysq

----------------
$ ./configure


There's a number of options to configure. The complete listing may be obtained by using --help switch. The most important ones are:

--prefix, which specifies where to install Sphinx; such as --prefix=/usr/local/sphinx (all of the examples use this prefix)
--with-mysql, which specifies where to look for MySQL include and library files, if auto-detection fails;
--with-pgsql, which specifies where to look for PostgreSQL include and library files.


3. Build the binaries:

$ make

- 다시빌드(-B) : # make -B

- make 실행시 발생하는 알려진 오류

-----------------------------------------------
/bin/sh: g++: command not found
make[1]: *** [libsphinx_a-sphinx.o] Error 127
-----------------------------------------------

 

위 경우,  gcc-c++ 패키지가 설치되었는지 확인한다.

gcc-c++ 설치방법 :

- 설치된 패키지 확인
#  rpm -qa | grep gcc

- yum 을 이용해 cc-c++ 패키지만 설치
# yum -y install gcc-c++

- yum 을 이용해 gcc와 gcc-c++ 패키만 설치
# yum install gcc gcc-c++

-----------------------------------------------
sphinx.cpp:67: error: invalid application of `sizeof' to
    incomplete type `Private::SizeError<false>'
-----------------------------------------------

위 경우, 어떤 컴파일-타임 형식 크기( type size ) 체크 실패를 의미한다. 대부분 문제는 off_t 형식이 시스템에서 64-bit 보다 작기 때문이다.
빠른 해결 방법은, sphinx.h 파일을 열고 typedef SphOffset_t 안에 off_t 를 DWORD 로 대체하고 저장한다. 그러나, 이 경우
2GB 보다 큰 full-text indexes 를 사용할 경우 제한을 받는다.

 

4. Install the binaries in the directory of your choice: (defaults to /usr/local/bin/ on *nix systems, but is overridden with configure --prefix)

 

$ make install

 

[Installing Sphinx on Windows]

 

1. Extract everything from the .zip file you have downloaded - sphinx-0.9.8-win32.zip (or sphinx-0.9.8-win32-pgsql.zip if you need PostgresSQL support as well.)
 You can use Windows Explorer in Windows XP and up to extract the files, or a freeware package like 7Zip to open the archive.

For the remainder of this guide, we will assume that the folders are unzipped into C:\Sphinx, such that searchd.exe can be found in C:\Sphinx\bin\searchd.exe.
 If you decide to use any different location for the folders or configuration file, please change it accordingly.


2. Install the searchd system as a Windows service:

C:\Sphinx> C:\Sphinx\searchd --install --config C:\Sphinx\sphinx.conf --servicename SphinxSearch

 

3. The searchd service will now be listed in the Services panel within the Management Console, available from Administrative Tools.
 It will not have been started, as you will need to configure it and build your indexes with indexer before starting the service.
 A guide to do this can be found under Quick tour.


<Sphinx 설정>

 - 가정 : /usr/local/sphinx 에 설치된것으로 가정한다.

1. configuration 파일 생성
 - 파일명 : sphinx.conf
 - 파일경로 :  /usr/local/sphinx/etc
 
 제공되는 샘플 configuration 파일을 sphinx.conf로 복사하여 사용한다.

$ cd /usr/local/sphinx/etc
$ cp sphinx.conf.dist sphinx.conf
$ vi sphinx.conf

 

 MySQL 샘플 테스트를 입력한다.(테스트를 위해)


$ mysql -u test < /usr/local/sphinx/etc/example.sql


2. Run the indexer to create full-text index from your data

$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/indexer

또는

#/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all

 

> 전체 인덱싱
# /usr/local/sphinx/bin/indexer --all

 

> 실행 중 전체 인덱싱
# /usr/local/sphinx/bin/indexer --all --rotate


- ./indexer 다음의 오류가 발생하면,

-----------------------------------------------
./indexer: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory
-----------------------------------------------

(1) /etc/ld.so.conf 파일을 열고 mysql library 경로를 추가한다. (예)/usr/local/mysql/lib/mysql


# vi /etc/ld.so.conf

 

(2) 다시 시작
# /sbin/ldconfig

 

3. 새롭게 인덱스가 생성되었다.

 

3.1 명령 라인에서 인덱스 쿼리를 위해 다음의 검색 유틸리티를 사용한다.

$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/search test

 

3.2 php 스크립트에서 인덱스 쿼리를 사용하고자 한다면,

 

>  search 데몬을 실행한다.

$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/searchd

 

> search 데몬 종료한다.

# pkill -9 searchd

 

(2) PHP API 가 포함된 테스트 스크립트를 실행한다.

 

$ cd sphinx/api     (실제, #cd /root/sphinx-0.9.8.1/api)
$ php test.php test
 또는
# /usr/local/php/bin/php -q test.php test

 

(3) API (경로: api/sphinxapi.php)를 자신의 스크립트에 포함하여 사용한다.

 

>  thank 문자 검색
# /usr/local/php/bin/php test.php none -a -i ac_ne thank
# /usr/local/php/bin/php test_tt.php

 

> 페이지를 매기는 한 가지 예는 검색 엔진을 호출하는 것이다.
$cl->SetLimits( ( $page - 1 ) * SPAN, SPAN )은

> 디스플레이 될 페이지에 따라서 첫 번째, 두 번째, 세 번째 일괄 SPAN 매치를 리턴한다.


(4) Shell 테스트


# /usr/local/sphinx/bin/search --config /usr/local/php/etc/sphinx.conf thank
# /usr/local/sphinx/bin/search thank
# /usr/local/sphinx/bin/search 왕미

 

(기타)

> tar로 압축하기
# tar cvf  sphinx_api.tar api/

 

> tar로 압축풀기
$ tar xvf sphinx_api.tar

 


Posted by 아이맥스