tar zxvf coreseek-4.1-beta.tar.gz
【mmseg】
cd coreseek-4.1-beta/mmseg-3.2.14
./configure --prefix=/usr/local/mmseg3
make && make install
提示config.status: error: cannot find input file: src/Makefile.in
执行以下命令:
aclocal
libtoolize --force
automake --add-missing
autoconf
autoheader
make clean
【csft】
cd coreseek-4.1-beta/csft-4.1
sh buildconf.sh
./configure --prefix=/usr/local/sphinx --without-unixodbc --with-mmseg=/usr/local/mmseg3/ --with-mmseg-includes=/usr/local/mmseg3/include/mmseg --with-mmseg-libs=/usr/local/mmseg3/lib/
make && make install
vim /usr/local/sphinx/etc/的配置文件
也可以直接将配置示例copy后直接修改
[测试]
cd ../testpack
cat var/test/test.xml
/usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml
#生成索引
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all
#启动服务
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf
#网络索引测试
/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/sphinx.conf
#crontab -e 加入crontab五分钟重新索引
*/5 * * * */usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --rotate --all
【安装php sphinx client 扩展】
tar xzvf sphinx-2.0.2-beta.tar.gz
cd /usr/local/src/sphinx-2.0.2-beta/api/libsphinxclient
#vim sphinxclient.c
找到
void sock_close ( int sock );
改为
static void sock_close ( int sock );
./configure --prefix=/usr/local/sphinxclient
make&&make install
tar zxvf sphinx-1.2.0.tgz
cd sphinx-1.2.0
/usr/local/zend/bin/phpize
./configure --with-php-config=/usr/local/zend/bin/php-config --with-sphinx=/usr/local/sphinxclient
make&&make install
#复制sphinx.so模块只php_extensions下
cp /usr/local/zend/lib/php/20090626/sphinx.so /usr/local/zend/lib/php_extensions/
#vim /usr/local/php-5.2.17/etc/php.ini #注意最加的位置
vim /usr/local/zend/etc/php.ini
追加
extension=sphinx.so
#根据实际情况重启php-pfm或这个apache
service fastcgi reload //usr/local/zend/apache2/bin/httpd restart
开放服务器端口
iptables -A INPUT -p tcp -m tcp --dport 9312 -j ACCEPT
【建立主索引、增量索引实现实时索引】
# in MySQLCREATE TABLE sph_counter( counter_id INTEGER PRIMARY KEY NOT NULL, max_doc_id INTEGER NOT NULL);# in sphinx.confsource main{ # ... sql_query_pre = SET NAMES utf8 sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM documents sql_query = SELECT id, title, body FROM documents \ WHERE id<=( SELECT max_doc_id FROM sph_counter WHERE counter_id=1 )}source delta : main{ sql_query_pre = SET NAMES utf8 sql_query = SELECT id, title, body FROM documents \ WHERE id>( SELECT max_doc_id FROM sph_counter WHERE counter_id=1 )}index main{ source = main path = /path/to/main # ... all the other settings}# note how all other settings are copied from main,# but source and path are overridden (they MUST be)index delta : main{ source = delta path = /path/to/delta}
#创建主索引
/usr/local/sphinx/bin/indexer shop --config /usr/local/sphinx/etc/sphinx.conf --rotate
#创建增量索引:
/usr/local/sphinx/bin/indexer delta --config /usr/local/sphinx/etc/sphinx.conf --rotate
#合并增量索引到主索引:
/usr/local/sphinx/bin/indexer --merge shop delta -c /usr/local/sphinx/etc/sphinx.conf --rotate
#创建所有索引
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all --rotate
#查询索引
/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/sphinx.conf -i delta -a 麦田
#根据索引源创建索引
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf onlineshop --rotate
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf testshop --rotate
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf betashop --rotate
计划任务
*/5 * * * * /usr/local/sphinx/bin/indexer delta --config /usr/local/sphinx/etc/sphinx.conf .conf --rotate;/usr/local/sphinx/bin/indexer --merge shop delta -c /usr/local/sphinx/etc/sphinx.conf --rotate
30 2 * * * /usr/local/sphinx/bin/indexer shop --config /usr/local/sphinx/etc/sphinx.conf --rotate