| 
 在 Ubuntu 14.04 下 apt-get 安装全文搜索引擎 Sphinx 工作环境: 
|  1 | 系统 | Ubuntu 14.04 |  |  2 | HTTP 代理 | nginx 1.4.6 |  |  3 | PHP 版本 | 5.5.9 |  |  4 | MySQL 版本 | 5.5.40 |  |  5 | phpMyAdmin 版本 | 4.0.10deb1 |  
  
安装步骤: 
       01、安装全文搜索引擎 Sphinx 前,必须先安装 MySQL server 并设置数据库 root 用户(此处不讲 MySQL server 的具体安装过程,请关注相关主题) 
 
       02、使用 apt-get 方法直接安装 Sphinx: 
- apt-get install sphinxsearch
 
  复制代码        智能批处理式 "数字 Python IDE" 集成开发环境 (集成高效 Cython PyInstaller 批处理小程序) http://dt.digitser.cn/zh-CN/ide/idepy/index.html  
多线程 批处理式 全文搜索 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_search/index.html 
 
 多线程 批处理式 全文搜索-文本 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_searchtext/index.html 
 
 
 多线程 批处理式 全文替换 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_replace/index.html 
 
 多线程 批处理式 全文替换-多 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_replacemany/index.html 
 
 多线程 批处理式 全文替换-文本 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_replacetext/index.html 
 
 
 多线程 批处理式 全文移动-文本 工具 
 http://dt.digitser.cn/zh-CN/applet/fulltext_move/index.html  
       03、创建全文搜索引擎 Sphinx 的配置文件: 
- cp /etc/sphinxsearch/sphinx.conf.sample /etc/sphinxsearch/sphinx.conf
 
 - vi /etc/sphinxsearch/sphinx.conf
 
  复制代码               配置全文搜索引擎 Sphinx 的配置文件: 
- sql_user = test
 
 - sql_pass =
 
 - # compat_sphinxql_magics = 1
 
  复制代码               将以上代码改为 
- sql_user = root
 
 - sql_pass = 您的数据库 root 用户密码
 
 - compat_sphinxql_magics = 0
 
  复制代码        04、开启 sphinxsearch 功能: 
- vi /etc/default/sphinxsearch
 
  复制代码               将其中的 
              改为 
       05、创建 test 数据库: 
- root:~# mysql -u root -p
 
  
- Enter password: 键入您的数据库 root 用户密码
 
  
- Welcome to the MySQL monitor.  Commands end with ; or \g.
 
 - Your MySQL connection id is 20177
 
 - Server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)
 
  
- Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 
  
- Oracle is a registered trademark of Oracle Corporation and/or its
 
 - affiliates. Other names may be trademarks of their respective
 
 - owners.
 
  
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
  
- mysql>create database test;
 
  
- Query OK, 1 row affected (0.00 sec)
 
  
- mysql> use test;
 
  
- Reading table information for completion of table and column names
 
 - You can turn off this feature to get a quicker startup with -A
 
  
- Database changed
 
  
- mysql> exit
 
  
- Bye
 
  
- root:~#
 
 
  复制代码        06、将 test 数据库范例文件 
- /etc/sphinxsearch/example.sql
 
  复制代码               下载到本地计算机 
 
       07、在浏览器中键入 
- http://您的服务器 IP 地址/phpmyadmin/
 
  复制代码               访问 phpMyAdmin 控制台-->键入您的数据库 root 用户名及密码-->选择 test 数据库-->导入-->浏览-->找到本地计算机 example.sql 文件-->打开-->执行-->显示 
- “导入成功,执行了 6 个查询。(example.sql)”
 
  复制代码               说明 example.sql 文件导入 test 数据库成功 
 
       08、建立全文搜索引擎 Sphinx 的索引: 
        09、启动全文搜索引擎 Sphinx 服务: 
- root:~# service sphinxsearch start
 
  
- Starting sphinxsearch: Sphinx 2.0.4-id64-release (r3135)
 
 - Copyright (c) 2001-2012, Andrew Aksyonoff
 
 - Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
 
  
- using config file '/etc/sphinxsearch/sphinx.conf'...
 
 - listening on all interfaces, port=9312
 
 - listening on all interfaces, port=9306
 
 - precaching index 'test1'
 
 - precaching index 'test1stemmed'                             
 
 - WARNING: multiple addresses found for 'localhost', using the first one (ip=127.0.0.1)
 
 - precaching index 'rt'
 
 - precached 3 indexes in 0.001 sec
 
 - sphinxsearch.
 
  
- root:~# 
 
 
  复制代码        10、测试搜索 EN 单词 test- root:~# /usr/bin/search test
 
  
- Sphinx 2.0.4-id64-release (r3135)
 
 - Copyright (c) 2001-2012, Andrew Aksyonoff
 
 - Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
 
  
- using config file '/etc/sphinxsearch/sphinx.conf'...
 
 - index 'test1': query 'test ': returned 3 matches of 3 total in 0.000 sec
 
  
- displaying matches:
 
 - 1. document=1, weight=2421, group_id=1, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=1
 
 -     group_id=1
 
 -     group_id2=5
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=test one
 
 -     content=this is my test document number one. also checking search within phrases.
 
 - 2. document=2, weight=2421, group_id=1, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=2
 
 -     group_id=1
 
 -     group_id2=6
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=test two
 
 -     content=this is my test document number two
 
 - 3. document=4, weight=1442, group_id=2, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=4
 
 -     group_id=2
 
 -     group_id2=8
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=doc number four
 
 -     content=this is to test groups
 
  
- words:
 
 - 1. 'test': 3 documents, 5 hits
 
  
- index 'test1stemmed': query 'test ': returned 3 matches of 3 total in 0.000 sec
 
  
- displaying matches:
 
 - 1. document=1, weight=2421, group_id=1, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=1
 
 -     group_id=1
 
 -     group_id2=5
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=test one
 
 -     content=this is my test document number one. also checking search within phrases.
 
 - 2. document=2, weight=2421, group_id=1, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=2
 
 -     group_id=1
 
 -     group_id2=6
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=test two
 
 -     content=this is my test document number two
 
 - 3. document=4, weight=1442, group_id=2, date_added=Mon Dec 22 15:30:18 2014
 
 -     id=4
 
 -     group_id=2
 
 -     group_id2=8
 
 -     date_added=2014-12-22 15:30:18
 
 -     title=doc number four
 
 -     content=this is to test groups
 
  
- words:
 
 - 1. 'test': 3 documents, 5 hits
 
  
- index 'rt': search error: failed to open /var/lib/sphinxsearch/data/rt.sph: No such file or directory.
 
  
- root:~#
 
  复制代码        11、好啦,一切 OK 
 
 
扫一扫关注 德云社区 微信公众号
  
版权声明: 
本文为独家原创稿件,版权归 德云社区,未经许可不得转载。 
 |