(1).下载3.4.1版本
http://sphinxsearch.com/downloads/current/
(2).配置数据源和索引(超精简版本)
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source question_src
{
type = mysql
sql_host = 187.99.929.99
sql_user = legaojiufeddssdg
sql_pass = HjwmzCwALiGSDGfdf
sql_db = learojiufengfdfd
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id,course_id,question_name \
FROM think_course_question
#sql_attr_uint = id
sql_attr_uint = course_id
}
index question
{
source = question_src
path = D:/test/indexData/
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = D:/test/log/searchd.log
query_log = D:/test/log/query.log
read_timeout = 5
max_children = 30
pid_file = D:/test/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:/test/data/
}(3).生成索引
indexer.exe -c ../etc/sphinx-min.conf question
(4).启动sphinx
./searchd.exe -c ../etc/sphinx-min.conf
(5).php启动查询
$cl = new SphinxClient (); $cl->SetServer($config['host'], $config['port']); $cl->SetConnectTimeout(1); $cl->SetLimits(0, $limit, 100); $res = $sphinxClient->Query($keyword, 'question');
项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...
001源码:/* * $xml_str是xml字符串 */ function xmltoarray($xml_str) { //禁止XML实体扩展攻击 libxml_disable_entity_loader(true); //拒绝包含...
md5/sha1+salt方式是目前各大cms常用的加密方式,虽然salt安全,但是各大md5网站也在研究这个方向,那么我们应该选择password_hash动态hash来助力,一种密码有多种hash结果.看代码模拟登陆.<?php //01.注册 $user ='zhang...
项目中使用服务来执行webservice,由于对方系统api不稳定,经常导致服务崩溃,只能重启,一个月差不多要重启一次。初期的解决办法是捕获异常,然后continue掉。<?php try { $url = 'http...
(1).前端文件:<form action="upload.php" method="post" enctype="multipart/form-data"> &...
<?php /** * daemonize让当前脚本为守护进程执行 * @param string $callback 匿名函数 */ function daemonize($callback) {...