Linux 系统下sphinx的安装及php扩展的配置流程

Linux 系统下sphinx的安装及php扩展的配置流程

安装sphinx

此文章出处已经不记得了
这边文章对原文章进行了下修改
我用的系统是centos6.4

cd /usr/local

官网下载Sphinx软件包:

wget http://sphinxsearch.com/files/sphinx-2.1.5-release.tar.gz 

 

tar zxvf sphinx-2.1.5-release.tar.gz

cd sphinx-2.1.5-release

./configure --prefix=/usr/local/sphinx

make

make install

安装完成

配置sphinx.conf文件

cd /usr/local/sphinx/etc

cp sphinx.conf.dist sphinx.conf

vim sphinx.conf 编辑完成

[root@root var]# mkdir data1

[root@root var]# mkdir data2

[root@root var]# mkdir data0

 

Sphinx管理命令:

1. 生成全部索引

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

若此时searchd守护进程已经启动,那么需要加上—rotate参数:

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

2. 启动searchd守护进程

/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf

 

 

3 使用search命令在命令行对索引进行检索

/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/sphinx.conf

4. 添加计划任务

创建data脚本(主索引)build_main0_index.sh

 

Vim  /usr/local/sphinx/bin/build_main0_index.sh 

添加内容:

#/bin/bash

/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf  main0 --rotate 

创建delta脚本(增量索引并合并索引)build_delta_index.sh

 

Vim /usr/local/sphinx/bin/build_delta0_index.sh 

添加内容:

#/bin/bash

/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf  delta0  --rotate 

/usr/local/sphinx/bin/indexer  --merge main0 delta0 --config  

/usr/local/sphinx/etc/sphinx.conf  --rotate

5. 赋予可执行权限

chmod +x /usr/local/sphinx/bin/build_main0_index.sh(赋予权限)

chmod +x /usr/local/sphinx/bin/build_delta0_index.sh(赋予权限)

6. searchd 设计成开机可执行项

Vim /etc/rc.local

添加:

/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf

7. 添加计划任务

crontab -e  

添加:

0 0 * * */bin/sh /usr/local/sphinx/bin/build_main0_index.sh 

0 * * * */bin/sh /usr/local/sphinx/bin/build_delta0_index.sh 

 

 

 

配置sphinx 扩展

 

1、先安装sphinxclient

cd /usr/local/sphinx-2.1.5-release/api/libsphinxclient

./configure --prefix=/usr/local/sphinxclient

Make

Make install

 2、安装sphinx扩展   // 此处进行了修改

wget http://pecl.php.net/get/sphinx-1.3.0.tgz

tar zxf sphinx-1.3.0.tgz

cd sphinx-1.3.0

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient/

make && make install

 

echo [sphinx]>>/usr/local/php/etc/php.ini

echo extension=sphinx.so>>/usr/local/php/etc/php.ini

 

OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


reboot

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值