美文网首页
linux下安装sphinx笔记!

linux下安装sphinx笔记!

作者: DragonersLi | 来源:发表于2020-08-24 10:51 被阅读0次
    先安装sphinxclient
    地址:http://sphinxsearch.com/downloads
    cd /usr/local/src #切换到存放安装包目录
    wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz #下载安装包
    
    tar xzvf sphinx-0.9.9.tar.gz #解压文件
    cd sphinx-0.9.9/api/libsphinxclient #切换目录 
    
    vim sphinxclient.c 
    找到:void sock_close ( int sock );
    改成:static void sock_close ( int sock );
    
    ./configure --prefix=/usr/local/sphinxclient
    make && make install
    make install后可获取扩展目录:
    
    安装sphinx扩展
    地址:http://pecl.php.net/package/sphinx
    wget http://pecl.php.net/get/sphinx-1.3.3.tgz
    tar zxvf sphinx-1.3.3.tgz
     cd sphinx-1.3.3
    /www/server/php/56/bin/phpize #当前php版本的phpize所在目录
    ./configure --with-php-config=/www/server/php/56/bin/php-config --with-sphinx=/usr/local/sphinxclient
    make && make install
    
    
    +-----------------------------------------------------------+
    |                       ! ERROR !                           |
    | The test-suite requires that proc_open() is available.    |
    | Please check if you disabled it in php.ini.               |
    +-----------------------------------------------------------+
    [root@paijinhua sphinx-1.3.3]# make install
    Installing shared extensions:     /www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/
    [root@paijinhua sphinx-1.3.3]# cd  /www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/
    [root@paijinhua no-debug-non-zts-20131226]# ls
    opcache.a  opcache.so  redis.so  sphinx.so  suhosin.so
    
    
    php.ini底部追加:

    [sphinx] extension=/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/sphinx.so

    或者:
    extension_dir = "/www/server/php/56/lib/php/extensions/no-debug-non-zts-20131226/"
       [sphinx]
    extension=sphinx.so
    
    重启php然后phpinfo查看sphinx安装信息!

    测试

    1、安装sphinx 请参照文档http://linux008.blog.51cto.com/2837805/622088
    demo:https://www.jianshu.com/p/6593d4121b9d
    ######2、编写测试文件 #vim sphinx.php
    
    <?php
         $s = new SphinxClient;
         setServer("localhost", 9312);
         $s->setMatchMode(SPH_MATCH_ANY);
         $s->setMaxQueryTime(3);
         $result = $s->query("demo");
         var_dump($result);
        ?>
        #/usr/local/php/bin/php sphinx.php   运行结果
        array(9) {
      ["error"]=>
      string(0) ""
      ["warning"]=>
      string(0) ""
      ["status"]=>
      int(0)
      ["fields"]=>
      array(5) {
        [0]=>
        string(6) "cat_id"
        [1]=>
        string(13) "provider_name"
        [2]=>
        string(12) "goods_number"
        [3]=>
        string(18) "promote_start_date"
        [4]=>
        string(8) "keywords"
      }
      ["attrs"]=>
      array(8) {
        ["goods_sn"]=>
        string(1) "3"
        ["goods_name"]=>
        string(1) "3"
        ["brand_id"]=>
        string(1) "1"
        ["goods_weight"]=>
        string(1) "5"
        ["market_price"]=>
        string(1) "5"
        ["shop_price"]=>
        string(1) "5"
        ["promote_price"]=>
        string(1) "5"
        ["gid"]=>
        string(10) "1073741825"
      }
      ["total"]=>
      int(0)
      ["total_found"]=>
      int(0)
      ["time"]=>
      float(0)
      ["words"]=>
      array(1) {
        ["demo"]=>
        array(2) {
          ["docs"]=>
          int(0)
          ["hits"]=>
          int(0)
        }
      }
    }
    

    相关文章

      网友评论

          本文标题:linux下安装sphinx笔记!

          本文链接:https://www.haomeiwen.com/subject/qvsmhktx.html