(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');
PHP的session文件夹默认保存在同一个文件,随着访客的增多,访问的速度会非常慢,例如部分管理系统后台每天登陆1000次,1个月就创建了30000个session文件,一年后是多少?假设这个系统的用户是上万人呢?方法1:每个网站使用自己的session文件夹,代码如下:<?php $pat...
if($_SERVER['REQUEST_METHOD'] == 'POST') { echo('This is post '); } elseif ($_SERVER['...
上篇文章已经讲解arrayacces的原理,现在来讲解下arrayaccess的实际应用。一个大型的互联网项目中必然会存在各种配置信息,例如多种数据库信息:mysql,tidb,mongodb,redis,某个业务模块单独的配置信息如比例,额度等等,那么该如何治理配置信息?PHP项目中大部分的框架都...
在使用ftok生成ipc进程通信key尝试将第二个参数项目标识符传入字符串报错:PHP Warning: ftok(): Project identifier is invalid,查阅资料发现第二个字符串只能是1个字符串,长度为1....
<?php //如果支持exec函数,可以使用的方式 exec('chcp 65001'); //如果exec函数因安全问题禁用,可以使用的方式 pclose(popen('chcp 65001', 'r'));...
PHP简单定时器可以通过pcntl_signal创建闹钟信号来实现。但是缺点很明显,性能一般,要自己实现守护进程,不支持毫秒级定时器,单进程不支持多个闹钟信号,不能跨平台运行event扩展支持的事件多,性能高。<?php //创建event配置.[空配置] $eventConfig ...