安装参考官方教程(http://www.coreseek.cn/products/products-install/install_on_bsd_linux/)
CoreSeek快速安装:
coreseek安装需要预装的软件:yum install make gcc g++ gcc-c++ libtool autoconf automake imake MySQL-devel libxml2-devel expat-devel
cd /usr/local/src
wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz(如果不能下载可以用迅雷下载后传到服务器解压)
tar -xzvf coreseek-3.2.14.tar.gz
cd coreseek-3.2.14
安装mmseg
cd mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略,如果出现error则需要解决,,如果出现permission denied是权限问题 chmod -R 777 ./bootstrap,其他地方出现相同问题也这样处理就行
./configure --prefix=/usr/local/mmseg3
make && make install
cd ..
安装完成后,mmseg使用的词典和配置文件将自动安装到/usr/local/mmseg3/etc中
安装coreseek
cd csft-3.2.14
sh buildconf.sh #输出的warning信息可以忽略,如果出现error则需要解决
./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql ##如果提示mysql问题,可以查看MySQL数据源安装说明
make && make install
cd ..
cd /usr/local/coreseek/etc
cp sphinx-min.conf.dist sphinx.conf
vi sphinx.conf
内容示例如下(localhost,DB_USER,DB_PASSWORD,DB_NAME自行修改)
以下是我的数据
source main
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =kobebryant24
sql_db = dgshop
sql_port = 3306 # optional, default is 3306
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT id,cat_id,add_time,goods_name \
FROM cms_goods
sql_attr_uint = cat_id
sql_attr_timestamp = add_time
sql_query_info = SELECT * FROM cms_goods WHERE id=$id
}
index main
{
source = main
path = /usr/local/coreseek/var/data/main
docinfo = extern
charset_dictpath = /usr/local/mmseg3/etc/
charset_type = zh_cn.utf-8
ngram_len = 0
}
indexer
{
mem_limit = 32M
}
searchd
{
port = 9312
log = /usr/local/coreseek/var/log/searchd.log
query_log = /usr/local/coreseek/var/log/query.log
read_timeout = 5
max_children = 30
pid_file = /usr/local/coreseek/var/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
}
然后根据以上配置建立索引文件
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
启动命令
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf
至此就可以通过php api调试测试了
![这里写图片描述](https://img-blog.csdn.net/20170422155535349?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzQ0MzIzNDg=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
我这里是在本地windows下调试的,具体方法可自行百度
另外,远程连接MYSQL提示Host is not allowed to connect to this MySQL server时
解决方法:
1。 改表法。
可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user;
mysql>quit
2. 授权法。
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器的dk数据库,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
这里参考http://joinyo.iteye.com/blog/1489380
博主用的第一个方法,刚开始发现不行,在网上查了一下,少执行一个语句 mysql>FLUSH RIVILEGES 使修改生效.就可以了
我这里用的第二种方法,简单粗暴