centos7.4+nginx+php5.6+coreseek+fphix安装记录

首先安装依赖:

yum  -y  install  make  gcc  gcc-c++  libtool  autoconf  automake  imake  mariadb  mariadb-server  mariadb-devel libxml2-devel expat-devel

然后下载软件包

git  clone  https://github.com/dollarphper/soft.git

下载过程中报错-bash: git: command not found,是因为没有安装git  安装在执行上面的命令yum install git

然后继续安装   

 

 1.进入目录   

cd  soft

2.压缩     

tar  -xzf  coreseek-4.1-beta.tar.gz

 3.安装mmseg    

cd  coreseek-4.1-beta/mmseg-3.2.14/
./bootstrap
./configure --prefix=/usr/local/mmseg3
make && make install

 然后安装coreseek:

1.进入目录 

cd  ../csft-4.1

 

 2.修改配置文件:
 vim configure.ac

将
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
修改为
AM_INIT_AUTOMAKE([-Wall foreign])

3.下载软件

yum  -y  install  patch

4.安装

sh  buildconf.sh
./configure  --prefix=/usr/local/coreseek  --without-unixodbc  --with-mmseg  --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/  --with-mmseg-libs=/usr/local/mmseg3/lib/  --with-mysql
make  &&  make install

make && make install   编译时报错:

1.sphinxexpr.cpp:1823:43: error: ‘ExprEval’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]

   T val = ExprEval ( this->m_pArg, tMatch ); // ‘this‘ fixes gcc braindamage

处理办法:

 #vim ./src/sphinxexpr.cpp

 1746                  T val = ExprEval ( this->m_pArg, tMatch );

 形式修改为  T val = this->ExprEval ( this->m_pArg, tMatch );

 1777                  T val = ExprEval ( this->m_pArg, tMatch );

 形式修改为  T val = this->ExprEval ( this->m_pArg, tMatch );

 1823                  T val = ExprEval ( this->m_pArg, tMatch );

 形式修改为  T val = this->ExprEval ( this->m_pArg, tMatch );

 

2./root/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22292: undefined reference to `libiconv_open'
 /root/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22310: undefined reference to `libiconv'
 /root/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22316: undefined reference to `libiconv_close'

 collect2: ld returned 1 exit status
 make[2]: *** [indexer] Error 1
 make[2]: Leaving directory `/root/coreseek-4.1-beta/csft-4.1/src'
 make[1]: *** [all] Error 2
 make[1]: Leaving directory `/root/coreseek-4.1-beta/csft-4.1/src'
 make: *** [all-recursive] Error 1

解决办法:

 编辑:
 vim ./src/Makefile文件
 将
 LIBS = -lm -lexpat -L/usr/local/lib
 改成
 LIBS = -lm -lexpat -liconv -L/usr/local/lib

添加上   -liconv   就好了!

 

5.测试

a. 进入测试目录:

cd  ../testpack/

b. 查看测试文件:

cat  var/test/test.xml

c. 测试中文分词:

/usr/local/mmseg3/bin/mmseg  -d  /usr/local/mmseg3/etc var/test/test.xml

d. 创建索引:

/usr/local/coreseek/bin/indexer  -c  etc/csft.conf  --all

e. 搜索测试:

/usr/local/coreseek/bin/search  -c  etc/csft.conf  李彦宏

6.PHP安装sphinx扩展:

a-1. 进入目录:

cd  ../csft-4.1/api/libsphinxclient/

a-2. 编译:

aclocal
libtoolize --force
automake --add-missing
autoconf
autoheader
make clean
./configure  --prefix=/usr/local/sphinxclient
make  &&  make install

a-3. 回到软件包目录:

cd  ../../../../

 

:::先下载sphinx   PHP5.6需要1.3.3版本  ↓下载命令

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

a-4. 解压:

tar  -xzf  sphinx-1.3.3.tgz

a-5. 安装php-devel:

 安装php扩展必须有php-devel,没有php-devel就缺少phpize,就不会产生源代码文件,

yum  -y  install  php  php-devel

a-6. 进入目录:

cd  sphinx-1.3.3

a-7. 安装:(请根据你的PHP路径安装)《文章底部有说明》

phpize
./configure --with-php-config=/usr/bin/php-config --with-sphinx=/usr/local/sphinxclient
make && make install

a-8. 开启php-sphinx扩展:(根据你的实际情况添加)《文章底部有说明》
vim /etc/php.ini

在末尾加上:
[sphinx]
extension=sphinx.so

复制配置文件:(根据你的下载 / 安装目录目录复制)

cp  /usr/local/coreseek/etc/sphinx.conf.dist  /usr/local/coreseek/etc/csft.conf
cp  /home/lee/sphinx/coreseek-4.1-beta/mmseg-3.2.14/data/*  /usr/local/mmseg3/etc/

修改配置文件:

刚刚复制的的配置文件,把数据修改成自己网站的配置

/usr/local/coreseek/etc/csft.conf

 

7.PHP测试sphinx

b-5. :复制二进制文件:

cp  /usr/local/coreseek/bin/*  /usr/bin/

b-6. 生成索引:

indexer --all --rotate

b-7. 启动服务:

searchd

b-8. 停止服务:

searchd  --stop

b-9-1. 编写测试脚本:

<?php
$sphinx = new SphinxClient();
$sphinx->SetServer("127.0.0.1",9312);
$sphinx->SetMatchMode(SPH_MATCH_ALL);
$sphinx->SetLimits(0, 20, 1000);
$sphinx->SetArrayResult(true);
$result = $sphinx -> query("one","test1");
var_dump($result);

 

注意事项:

          1.启动 searchd  服务后请 netstat -lnp|grep searchd查看端口 | 进程是否存在!

          2.PHP文件上用的地址是进程上的ip和端口,请注意。

          3.有错误是请用 $sphinx = new SphinxClient()接收的变量输出一下报错内容;$sphinx->getLastError();

          4.更新了sphinx(coreseek)的配置时如果服务启动了请用  indexer --all --rotate  重建一下索引。  --all代表重建所有索引,可以更换为你的索引名;

          5.多版本PHP开发请注意   安装PHP-sphinx扩展请相对你的PHP版本,并使用需要这个扩展的PHP文件夹的phpize解析安装。路径请和你需要的安装的PHP路径相对。

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值