Sphinx+PHP+Mysql高效搜索web搭建

搭建了个社工库,框架是Sphinx+PHP+Mysql。

搭建教程:

先导入md5.sql

下载sphinx  http://sphinxsearch.com/  我用的是windows版的  当然linux也差不多

创建配置文件sphinx-zh/bin/sphinx.conf

#
# Minimal Sphinx configuration sample (clean, simple, functional)
#

source src1
{
type = mysql

sql_host = localhost
sql_user = root
sql_pass = 1141056911
sql_db = md5
sql_port = 3306

sql_query = SELECT `id`,`username`,`password`,`email`,`salt`,`order` FROM md5_sgk

sql_query_info = SELECT * FROM md5_sgk WHERE id=$id
}

index test1
{
source = src1
path = D:/sphinx-zh/data/
docinfo = extern
charset_type = utf-8
chinese_dictionary = D:/sphinx-zh/etc/xdict
}

indexer
{
mem_limit = 256M
}

searchd
{
listen = 9312
listen = 9306:mysql41
log = D:/sphinx-zh/log/searchd.log
query_log = D:/sphinx-zh/log/query.log
read_timeout = 5
max_children = 30
pid_file = D:/sphinx-zh/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:/sphinx-zh/1
}

然后执行命令创建索引

C:\Documents and Settings\Administrator>cd D:\sphinx-zh\bin

C:\Documents and Settings\Administrator>cd /d D:\sphinx-zh\bin

D:\sphinx-zh\bin>indexer --all

 

文 / Aex
LEAVE A REPLY
loading