- PostgreSQL Fulltext
- Sphinx Fulltext
- MySQL Fulltext
- phpBB Native Fulltext
首先要在你的服务器上安装 sphinx 搜索服务。目前这个版本是 Sphinx 2.2.11,可以在 phpBB 3.3.3上正常运行。
简单介绍一下我这里的设置以及环境。
debian10
phpBB 3.3.3
首先安装sphinxsearch。
代码: 全选
sudo apt install sphinxsearch
代码: 全选
sudo mkdir /home/sphinx-phpbbchinese
sudo mkdir /home/sphinx-phpbbchinese/log
sudo chown sphinxsearch:sphinxsearch -R /home/sphinx-phpbbchinese/
搜索设置 》 搜索后端 选择 Sphinx Fulltext
选择后,页面中出现 Sphinx Fulltext 的配置相关的参数。
包括数据文件夹路径,我这里手工修改为 /home/sphinx-phpbbchinese/
主机和端口使用默认的就可以。
内存限制根据你的服务器内存的大小来选择。我这里选择256M
这些修改好之后,点击提交保存。
回到这个配置页面,全选复制 sphinx 配置文件内容。
之后,到 维护 》 搜索索引 ,删除不再使用的搜索引擎的索引,再在 Sphinx Fulltext 创建索引
使用 SSH 登录你的服务器的终端界面。
编辑 /etc/sphinxsearch/sphinx.conf 文件
把上一步所复制的内容,黏贴进去。
在index段额外加入下面的红色内容,不然会非常影响搜索结果。
记得里面的数据库用户和密码用 mysql 的对应用户替换。index index_phpbb_1sqh9wuud70fuxy8_main
{
path = /xxxxxxxxxxx/index_phpbb_1sqh9wuud70fuxy8_main
source = source_phpbb_1sqh9wuud70fuxy8_main
docinfo = extern
morphology = none
stopwords =
wordforms = # optional, specify path to wordforms file. See ./docs/sphinx_wordforms.txt for example
exceptions = # optional, specify path to exceptions file. See ./docs/sphinx_exceptions.txt for example
min_word_len = 2
charset_table = U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF
ignore_chars = U+0027, U+002C
min_prefix_len = 3 # Minimum number of characters for wildcard searches by prefix (min 1). Default is 3. If specified, set min_infix_len to 0
min_infix_len = 0 # Minimum number of characters for wildcard searches by infix (min 2). If specified, set min_prefix_len to 0
html_strip = 1
index_exact_words = 0 # Set to 1 to enable exact search operator. Requires wordforms or morphology
blend_chars = U+23, U+24, U+25, U+26, U+40
#####################
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
}
保存退出。
将sphinx用systemd管理,注意根据你的实际目录进行修改
代码: 全选
sudo vim /etc/systemd/system/sphinx.service
代码: 全选
[Unit]
Description=SphinxSearch Search Engine
After=network.target remote-fs.target nss-lookup.target
After=syslog.target
[Service]
Type=forking
User=sphinxsearch
Group=sphinxsearch
# Run ExecStartPre with root-permissions
PermissionsStartOnly=true
ExecStartPre=/usr/bin/chown sphinxsearch.sphinxsearch /home/sphinx-phpbbchinese
# Run ExecStart with User=sphinxsearch / Group=sphinxsearch
ExecStart=/usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf
ExecStop=/usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf --stopwait
KillMode=process
KillSignal=SIGTERM
SendSIGKILL=no
LimitNOFILE=infinity
PIDFile=/home/sphinx-phpbbchinese/searchd.pid
[Install]
WantedBy=multi-user.target
Alias=sphinxm@.service
Alias=searchdm@.service
代码: 全选
sudo systemctl enable --now sphinx
代码: 全选
sudo systemctl status sphinx
代码: 全选
sudo -u sphinxsearch indexer --all
代码: 全选
sudo systemctl restart sphinx.service
下面的这段 ID: 1sqh9wuud70fuxy8,在上面的配置文件中可以找到。
代码: 全选
0 * * * * sudo -u sphinxsearch /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf index_phpbb_1sqh9wuud70fuxy8_main >> /home/sphinx-phpbbchinese/log/indexer.log 2>&1 &
0 * * * * sudo -u sphinxsearch /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf index_phpbb_1sqh9wuud70fuxy8_delta >> /home/sphinx-phpbbchinese/log/indexer.log 2>&1 &