Mar 23

linux下安装sphinx 不指定

bkkkd , 09:25 , 开发应用 , 评论(1) , 引用(0) , 阅读(13475) , Via 本站原创 | |
sphinx的搜索效率和结果都让人觉得很满意.所以我推荐做站内搜索的朋友可以使用sphinx来作为后台的搜索服务.

下载安装文件可以到http://sphinxsearch.com/downloads.html选择你合适版本的安装文件.下面使用源码安装.

wget http://sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
tar zxvf ./sphinx-0.9.9.tar.gz
cd /sphinx-0.9.9/
./configure --prefix=/usr/local/sphinx/
make
make install


添加用户

adduser searchd -r -M


在/ect/init.d/创建searchd 文件内容如下(其实在/usr/local/sphinx/bin/下也有一个searchd文件,不过我使用的时候,发现有错误,就自己重新改了.)

#!/bin/bash
#
# Init file for searchd
#
# chkconfig: 2345 55 25
#
# description: searchd
#
# USE "chkconfig --add searchd" to configure Sphinx searchd service
#
# by Vladimir Fedorkov Mar 1, 2006, info@astellar.com
# public domain

SUDO_USER=searchd

BASE_PATH=/usr/local/sphinx
PID_FILE=$BASE_PATH/var/log/searchd.pid
CONFIG_FILE=$BASE_PATH/etc/sphinx.conf

EXEC_PATH=$BASE_PATH/bin
DATA_PATH=$BASE_PATH/var/data
LOG_PATH=$BASE_PATH/var/log

RETVAL=0
prog="searchd"

do_config() {
  mkdir -p $DATA_PATH
  mkdir -p $LOG_PATH
  chown -R $SUDO_USER $DATA_PATH
  chown -R $SUDO_USER $CONFIG_FILE
  chown -R $SUDO_USER $LOG_PATH

  chmod 600 $CONFIG_FILE
  chmod u+rwx $EXEC_PATH/*
  chmod -R u+rw,go-rwx $DATA_PATH
  chmod -R u+rw,go-rwx $LOG_PATH
}

do_start() {
  echo "Starting $prog"
  sudo -u $SUDO_USER $EXEC_PATH/$prog --config $CONFIG_FILE
  RETVAL=$?
  echo
  return $RETVAL
}

do_stop() {
  echo "Stopping $prog"
  if [ -e $PID_FILE ] ; then
    kill -15 `cat $PID_FILE`
    sleep 5
    if [ -e $PID_FILE ] ; then
      kill -9 `cat $PID_FILE`
    fi
  fi
  RETVAL=$?
  echo
  return $RETVAL
}

case $* in

config)
  do_config
  ;;

start)
  do_start
  ;;

stop)
  do_stop
  ;;

restart)
  do_stop
  do_start
  ;;

*)
  echo "usage: $0 {start|stop|restart|config}" >&2

  exit 1
  ;;
esac

exit $RETVAL

Tags: , ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]