1、下载sphinx:
wget http://sphinxsearch.com/files/sphinx-2.2.8-release.tar.gz
2、开始编译
$ tar xzvf sphinx-2.2.8-release.tar.gz$ cd sphinx$ ./configure$ make$ make install
编译的时候有几个参数可以选择,我安装的时候是默认的,没有加以下任何的参数:
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-static-mysql, which builds Sphinx with statically linked MySQL support;--with-pgsql, which specifies where to look for PostgreSQL include and library files.--with-static-pgsql, which builds Sphinx with statically linked PostgreSQL support;
如果想知道,安装的文件在哪?可以使用以下的命令查看:
$ ./configure --help
如果你下载的是rpm包可以使用以下命令查看安装路径:
$ rpm -qpl sphinx-2.2.8-1.rhel7.x86_64.rpm #查看文件安装在哪
3、配置文件在/usr/local/etc/sphinx.conf,默认这个文件不存在,但是/usr/local/etc/目录下有sphinx.conf.dist
copy sphinx.conf.dist sphinx.conf
配置文件简单的如下:
#源source mrblog_article{ type = mysql sql_host = localhost sql_user = root sql_pass = qqq111!!! sql_db = mrblog sql_port = 3306 sql_query_pre = SET NAMES utf8 sql_sock = /tmp/mysql.sock sql_query = \ SELECT id, article_id, title, summary, content, added_date \ FROM bk_search_index ##WARNING: attribute 'id' not found - IGNORING #出现这个的原因是因为不能使用主键,且上面的查询语句默认且必需第一个字段是id sql_attr_uint = article_id sql_attr_timestamp = added_date sql_ranged_throttle = 100}#索引index mrblog_article_1{ source = mrblog_article path = /alidata/sphinx/data/mrblog_article_1 docinfo = extern dict = keywords mlock = 0 morphology = none min_word_len = 1 ngram_len = 1 ngram_chars = U+3000..U+2FA1F html_strip = 100}source mrblog_articlethrottled : mrblog_article{ sql_ranged_throttle = 100}index rt{ type = rt path = /alidata/sphinx/data/rt rt_field = title rt_field = content rt_attr_uint = gid}indexer{ mem_limit = 128M}searchd{ listen = 9312 log = /alidata/sphinx/log/searchd.log query_log = /alidata/sphinx/log/query.log read_timeout = 5 client_timeout = 300 max_children = 30 persistent_connections_limit = 30 pid_file = /alidata/sphinx/data/searchd.pid preopen_indexes = 1 unlink_old = 1 mva_updates_pool = 1M max_packet_size = 8M max_filters = 256 max_filter_values = 4096 max_batch_queries = 32 workers = threads # for RT to work}common{}
4、生成索引
/usr/local/bin/indexer --config /usr/local/etc/sphinx.conf --all --rotate
6、启动sphinx
/usr/local/bin/searchd --config /usr/local/etc/sphinx.conf
7、安装php扩展:请移步:
8、php如何处理:请稳步: