1. 程式人生 > >centOS6.5安裝coreseek,php+mysql+coreseek除錯測試,親測管用

centOS6.5安裝coreseek,php+mysql+coreseek除錯測試,親測管用

安裝參考官方教程(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 使修改生效.就可以了
我這裡用的第二種方法,簡單粗暴

注:參考博文http://blog.csdn.net/keyunq/article/details/45129867