PHP Connection Sphinx:
A. Installation extension:
A-1. Enter directory:cd ../csft-4.1/api/libsphinxclient/
A-2. Compile:
aclocallibtoolize --forceautomake --add-missingautoconfautoheadermake clean./configure --prefix=/usr/local/sphinxclientmake && make install
A-3. Back to the package directory:
cd ../../../../
A-4. Extract:
tar -xzf sphinx-1.3.0.tgz
A-5. Install Php-devel:
yum -y install php php-devel
A-6. Enter directory:
cd sphinx-1.3.0
A-7. Installation:
phpize./configure --with-php-config=/usr/bin/php-config --with-sphinx=/usr/local/sphinxclientmake && make install
A-8. To open the Php-sphinx extension:
Vim/etc/php.ini
在末尾加上:[sphinx]extension=sphinx.so
B. Testing:
B-1. To start the MARIADB service:
systemctl start mariadb
B-2. To add test data:
mysql -uroot -p123456 < /usr/local/coreseek/etc/example.sql
B-3. To copy a configuration file:
cp /usr/local/coreseek/etc/sphinx.conf.dist /usr/local/coreseek/etc/csft.confcp /home/lee/sphinx/coreseek-4.1-beta/mmseg-3.2.14/data/* /usr/local/mmseg3/etc/
B-4. To modify a configuration file:
Vim/usr/local/coreseek/etc/csft.conf
SOURCE Src1{type = Mysqlsql_host = Localhostsql_user = Rootsql_pass = 123456sql_db = Testsql_port = 3306 # optional, default is 3306sql_query_pre = SET NAMES Utf8sql_sock =/var/lib/mysql/mysql.s Ocksql_query = SELECT ID, group_id, Unix_timestamp (date_added) as date_added, title, content from DOCUMENTSS Ql_attr_uint = Group_idsql_attr_timestamp = Date_addedsql_ranged_throttle = 0sql_query_info_pre = SET NAMES utf8sql _query_info = SELECT * from documents WHERE id= $id}source src1throttled:src1{sql_ranged_throttle = 100}index test1{ Source = Src1path =/usr/local/coreseek/var/data/test1docinfo = Externmlock = 0morph ology = Nonemin_word_len = 1html_strip = 0charset_dictpath =/usr/local/mmseg3/etc/charset_type = Zh_cn.utf-8}indexer{mem_limit = 128m}searchd{listen = 9312listen = 9306:mysql41log =/usr/ local/coreseek/var/log/sEarchd.logquery_log =/usr/local/coreseek/var/log/query.logread_timeout = 5client_timeout = 300max_child ren = 30pid_file =/usr/local/coreseek/var/log/searchd.pidmax_matches = 1000seamless_rotate = 1preop en_indexes = 1unlink_old = 1mva_updates_pool = 1mmax_packet_size = 8mmax_filters = 256max_filter_value s = 4096max_batch_queries = 32workers = threads # for RT-to-work}
B-5. : Copy the binary file:
cp /usr/local/coreseek/bin/* /usr/bin/
B-6. Build index:
indexer --rotate --all
B-7. Start the service:
searchd
B-8. Stop service:
searchd --stop
B-9. Test:
B-9-1. To write a test script:
Vim test.php
<?php$sphinx = new SphinxClient();$sphinx->SetServer("127.0.0.1",9312);$sphinx->SetMatchMode(SPH_MATCH_ALL);$sphinx->SetLimits(0, 20, 1000);$sphinx->SetArrayResult(true);$result = $sphinx -> query("one","test1");var_dump($result);
B-9-2. To run the script:
PHP test.php
Four