Ubuntu in Production: Install Sphinx Search, with PHP(转载)

 

转载自: http://fideloper.com/production-ubuntu-install-sphinx-search

 

If you need or want a great full-text search engine, and you decide on Sphinx Search, here's how to install it on Ubuntu. I'm using 12.04 LTS Ubuntu Server.

This assumes two things:

  1. You want to use Sphinx Search
  2. You'll be searching the Sphinx index with PHP

Note: This is how I got it to work with PHP after a few hours of testing. There may be better ways (Installing it easy, getting PHP to work with it had a road-bump).

Installing

$ sudo apt-get install sphinxsearch

Well, that was easy. Sphinx is now installed. It's three main scripts are:

  • indexer - Indexes the data based on configuration file
  • searchd - Search daemon that runs in background
  • search - CLI tool to test searches

Next, getting PHP to work with it. This is the tricky part. Documentation says to use PEAR/PECL. Try that, and you'll get an ugly error:

$ sudo pear install pecl/sphinx
... lots of ugly output
... blah blah blah, missing libsphinxclient

We need libsphinxclient. This means going to the binary and building it using make/make install. But fear not, this is pretty easy - and there's no need to compile php.

From there, you can follow these instructions to make libspshinxclient and install the PECL library:

$ tar -xvf sphinx-2.0.6-release.tar.gz #You're version may differ
$ cd sphinx-2.0.6-release/api/libsphinxclient
$ ./configure
$ make
$ sudo make install

Now, this should work:

$ sudo pecl install sphinx
$ echo "extension=sphinx.so" >> /etc/php5/conf.d/sphinx.ini
$ sudo service apache2 restart

Here is a same PHP class, config file, and a simpler version of the instructions above for setting up Sphinx Search in Ubuntu.

Here's a Symfony 2 Sphinx Search package.

 

Here's an example of setting up Sphinx and searching with it.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值