1. 原理:
    1. 使用sphinx 中的indexer 生成索引数据
    2. service/web 端 利用searched 调用索引数据
  2. 步骤:
    1. 下载 sphinx:
      1. 下载地址:http://sphinxsearch.com/downloads/release/  这个可以根据自己电脑的系统来下载相应的安装包。
      2. ps:我是mac,所以 我下载了mac安装包,按照文档上的安装 发现不行,后来 我下载了第一个 即 Source tarball (tar.gz), 才安装成功的。
    2. 安装sphinx
      1. 参考地址:http://sphinxsearch.com/docs/current.html#compiling-from-source  一步步来就可以了。主要是 configure的配置,其他都一样。我是xampp 所以写成 ./configure --prefix=/usr/local/sphinx --with-mysql=/Applications/XAMPP/xamppfiles。然并卵,./configure --prefix=/usr/local/sphinx 其实就可以了。
      2. cd /usr/local/sphinx/ 查看 这个目录下,有了bin,etc,var 三个文件夹,就是安转成功了。
    3. 使用sphinx 中的indexer工具 来 对数据表 建立索引数据
      1. indexer 的位置: /usr/local/sphinx/bin
      2. 方法:bin/indexer -c etc/sphinx.conf test1
      3. 问题1:sphinx.conf 是什么 。
        1. sphinx.conf 是 sphinx 的配置文件
        2. 位置 /usr/local/sphinx/etc,没有的话,自己新建一个或者复制一个
      4. 问题2:test1 是什么:需要建立索引文件的 索引名称,在配置文件中有些
      5. 所以需要先 配置好 sphinx.conf 文件,
        1. 参考地址:http://www.sphinxsearch.org/sphinx-tutorial
        2. 参考地址:http://www.apoyl.com/?p=290
        3. 各个配置项的说明,参考:http://sphinxsearch.com/docs/current.html#conf-reference
        4. 配置好各个参考。保存,执行3.1。居然报错,提示语:Library not loaded: libmysqlclient.18.dylib 网上 查了下,貌似是 文件不存在
        5. 参考地址:http://blog.sina.com.cn/s/blog_68f3bc280100supn.html
        6. 因为我用的是xampp,并不是原生态的mysql,所以文件不存在 也是合理的。
        7. 我去xampp中找到了 类似文件 /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib。然后执行 sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib  /usr/lib/libmysqlclient.18.dylib
        8. 在 执行 3.1 的命令行。发现 ok了。
        9. 查看 cd /usr/local/sphinx/var/data/.(sphinx.conf文件里面有些索引的路径即 path) 发现 存在了 。
        10. 这些数据,既 针对test1的索引数据,生成成功了。
      6.   ps:--rotate参数可以在不停searchd的情况下索引,不然的话会有类似如下的提示:
          FATAL: failed to lock /usr/local/...... Resource temporarily unavailable, will not index. Try --rotate option.
          方法:bin/indexer -c etc/sphinx.conf test1 --rotate
    4. 测试索引是否可以使用
      1. /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf --status
    5. 查看sphinx 的数据
      1. mysql -h0 -P9306
      2. 使用mac 自带的终端 输入  mysql -h0 -P9306,怎么没起到作用,我去(command not found)。
      3. 原来当你输入命令时,系统会在/usr/bin这个位置里寻找你输入的命令,如果你没有把命令引入到这个位置,无论你直接cd到工具具体的位置调用,也是白费功夫的。只要把这个工具的绝对位置引入到/usr/bin,所有的问题就迎刃而解了,只要我们把这条命令执行

        sudo ln /Applications/XAMPP/xamppfiles/bin/mysql /usr/bin 
      4. 此时 我们再次输入 mysql -h0 -P9306,就可以进入sphinx的数据库了。
      5. 再附上 进入mysql数据库的命令行 :mysql -u root -p
    6. 我的配置:
      1. mac os x 10.10.5
      2. x86_64
      3. xampp

mac 下 sphinx + mysql + php 实现全文搜索(xampp)(1)的更多相关文章

  1. mac 下 sphinx + mysql + php 实现全文搜索(xampp)(3)sphinx 的配置项解析

    source:数据的来源,数据是从什么地方来的. index:索引,当有数据源之后,从数据源处构建索引.索引实际上就是相当于一个字典检索.有了整本字典内容以后,才会有字典检索. searchd:提供搜 ...

  2. mac 下 sphinx + mysql + php 实现全文搜索(xampp)(4)php api 解析

    1:function GetLastError()  // 假如报错的话,会输出报错信息 2:function GetLastWarning ()// 输出 警告信息 3:function SetSe ...

  3. 配置apache,及mac下安装mysql

    先打开apache,在浏览器上输入  localhost     回车后会如果屏幕上显示:It works! 如下图: 这说明你的apache已开启 在window下配置apache: 1.找到apa ...

  4. mac 初次配置apache,及mac下安装mysql

    先打开apache,在浏览器上输入  localhost     回车后会如果屏幕上显示:It works! 如下图: 这说明你的apache已开启 mac 下apache配置(mac自带apache ...

  5. mac 下安装 mysql (蛋疼)

    mac先安装mydql步骤 1.首先从官网上下载 mac版本的mysql:我的是mysql-5.7.20-macos10.12-x86_64.dmg 2.正常安装: 3.在系统偏好设置的最底下.1:是 ...

  6. Mac下安装MySQL 5.6.40

    Mac下安装MySQL 5.6.40 - 干勾鱼的CSDN博客 - CSDN博客   原创 Mac下安装MySQL 5.6.40 2018-06-18 10:34:03 我是干勾鱼 阅读数 5927 ...

  7. mac 下卸载mysql的方法

    今天在mac上瞎折腾时,把mysql玩坏了,想卸载重装,却发现找不到卸载程序,百度了下,将操作步骤备份于此: cd ~/ sudo rm /usr/local/mysqlsudo rm -rf /us ...

  8. Mac下安装Mysql出现 Can’t connect to local MySQL server through socket '/tmp/mysql.sock'

    在Mac下安装mysql出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock' 错误,解决如下: $ unset ...

  9. Mac下安装MySQL及启动等常用命令

    总结了下mac下的mysql安装步骤:   eclipse JavaEE 下载         JDK -9 macosx下载   一.安装及启动服务 1. MySQL Server 下载.(以mys ...

随机推荐

  1. Windows环境下安装导入tornado

    首先,一台安装并配置好了python,我的python版本的肯定是2.7,直接进入tornado的环节: 下载tornado的压缩包,我的下载地址为:https://codeload.github.c ...

  2. CF Exam (数学)

     Exam time limit per test 1 second memory limit per test 256 megabytes input standard input output s ...

  3. LeetCode 326

    Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: ...

  4. LeetCode 152

    Maximum Product Subarray Find the contiguous subarray within an array (containing at least one numbe ...

  5. Hexo中添加emoji表情

    国庆的三天假前,都是玩CF和LOL的无限乱斗过来的,输了怨没随机到好的英雄,赢了就高高兴兴的

  6. html accesskey (단축키 지정)

    accesskey 속성은 마우스 등을 쓰지 않는 환경을 위해 링크나 입력 폼에서 키보드의 키 입력만으로 동작을 실행할 수 있도록 accesskey 속성값에 access 할 영어 또 ...

  7. Annotation注解与butterknife

    注解分为三种,一般来讲我们使用的是运行时会加载及能够反射读取的注解类型, 其他编译器生效的类型和编译后放入类文件而运行期不能加载解析的对我们没啥用. 所以从普通理解上来看,注解要配合着反射用就好了. ...

  8. ubuntu(16.04.01)学习-day2--高级命令

    1.查找命令 find -name "hello.c" grep "test" grep "usb" -c -r /drivers/usb ...

  9. Android之手机屏幕的获取

    屏幕区域的获取: activity.getWindowManager().getDefaultDisplay(); 应用区域的获取: Rect outRect = new Rect(); activi ...

  10. 文件流操作(FileStream,StreamReader,StreamWriter)

    大文件拷贝: /// <summary> /// 大文件拷贝 /// </summary> /// <param name="sSource"> ...