- 论坛徽章:
- 0
|
安装Sphinx 搜索引擎(google)
Installing Sphinx on Linux
Extract everything from the distribution tarball (haven't you already?) and go to the sphinx subdirectory:
$ tar xzvf sphinx-0.9.8.tar.gz
$ cd sphinx
Run the configuration program:
$ ./configure
![]()
Error 不能找到mysql-devel,需要手工安装mysql-devel包
./configure --with-mysql
yum --list |grep mysql-devel
yum install mysql-devel.i586
3.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.
Build the binaries:
$ make
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
$ cd /usr/local/sphinx/etc
| $ cp sphinx.conf.dist sphinx.conf
| $ vi sphinx.conf
| $ mysql -u test
2. Run the indexer to create full-text index from your data:
| $ cd /usr/local/sphinx/etc
| $ /usr/local/sphinx/bin/indexer
Quick Sphinx usage tour
All the example commands below assume that you installed Sphinx in /usr/local/sphinx, so searchd can be found in /usr/local/sphinx/bin/searchd.
To use Sphinx, you will need to:
Create a configuration file.
Default configuration file name is sphinx.conf. All Sphinx programs look for this file in current working directory by default.
Sample configuration file, sphinx.conf.dist, which has all the options documented, is created by configure. Copy and edit that sample file to make your own configuration: (assuming Sphinx is installed into /usr/local/sphinx/)
$ cd /usr/local/sphinx/etc
$ cp sphinx.conf.dist sphinx.conf
$ vi sphinx.conf
Sample configuration file is setup to index documents table from MySQL database test; so there's example.sql sample data file to populate that table with a few documents for testing purposes:
$ mysql -u test
Run the indexer to create full-text index from your data:
$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/indexer
Query your newly created index!
To query the index from command line, use search utility:
$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/search test
To query the index from your PHP scripts, you need to:
Run the search daemon which your script will talk to:
$ cd /usr/local/sphinx/etc
$ /usr/local/sphinx/bin/searchd
Run the attached PHP API test script (to ensure that the daemon was succesfully started and is ready to serve the queries):
$ cd sphinx/api
$ php test.php test
Include the API (it's located in api/sphinxapi.php) into your own scripts and use it.
Happy searching!
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111851/showart_2183334.html |
|