跳轉到內容
View in the app

A better way to browse. Learn more.

PHP論壇人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

vBulletin 6.0 Sphinx CJK 中文搜索 (宝塔面板)

精選回覆

發表於

Sphinx手册
https://www.sphinx-doc.org/en/master/

vBulletin官方的Sphinx教程
https://www.vbulletin.com/docs/html/main/acp_settings_searchtype

https://www.vbulletin.com/docs/html/acp_searchtype_sphinx_linux

------------------------------------------------------------------------------------------

vBulletin 6.0 Sphinx CJK 中文搜索  (宝塔面板)

教程环境:Rocky Linux 8、宝塔面板、MySQL 5.7、PHP 8.0

注意:宝塔面板的软件商店有sphinx,不过无法使用

 

如果你发现宝塔面板配置 vBulletin 6.0 Sphinx CJK 中文搜索,有出现其他的错误消息

请到 LNMP一键包

下载帖子附件 vbulletin-sphinx.php (zip包) 并使用这个版本

重新再修改 vbulletin-sphinx.php 中的宝塔面板路径

 

 

-----------------------------------------------------------------
安装套件、依赖包
-----------------------------------------------------------------


安装java
yum -y install java

 

安装python3.11
yum -y install python3.11


安装 python3.11-devel
yum -y install python3.11-devel

 

安装glibc
yum -y install glibc

 

安装gcc-c++
yum -y install gcc-c++

 

安装mysql-devel
yum -y install mysql-devel

 

安装pip
wget https://bootstrap.pypa.io/get-pip.py

python3.11 get-pip.py --user

 

 

安装Jpype1
pip3.11 install Jpype1

 

 

安装 libpq 13.11
yum -y install libpq

 


pip安装sphinx,也许需要相关的依赖包
pip3.11 install --user sphinx


-----------------------------------------------------------------
下载Sphinx二进制包 & make编译
-----------------------------------------------------------------

Sphinx官网下载
http://sphinxsearch.com/downloads


注意:Sphinx版本太旧、太新的版本会在后续有错误!

 

安装 Sphinx 3.0.1
http://sphinxsearch.com/downloads/sphinx-3.0.1-7fec4f6-linux-amd64.tar.gz/thankyou.html


下载完成,再上传到自己的服务器,放在 /usr/local/ 目录

cd /usr/local/

tar zxf sphinx-3.0.1-7fec4f6-linux-amd64.tar.gz

 

将sphinx-3.0.1目录,更名为sphinx
mv sphinx-3.0.1-7fec4f6-linux-amd64 sphinx

 

编译
cd /usr/local/sphinx/api/libsphinxclient

./configure --enable-id64 --prefix=/usr/local/sphinx

make && make install

 

-----------------------------------------------------------------
在 /usr/local/ 创建目录
-----------------------------------------------------------------

mkdir /usr/local/sphinx/log

mkdir /usr/local/sphinx/data

 

 

-----------------------------------------------------------------
配置vBulletin论坛的config.php
-----------------------------------------------------------------

在 论坛根目录/core/includes/config.php 文件的末尾,添加以下内容:

vi /www/wwwroot/域名.com/core/includes/config.php

//  Sphinx configuration parameters
$config['Misc']['sphinx_host']    = '127.0.0.1';
$config['Misc']['sphinx_port']    = '9306';
$config['Misc']['sphinx_path']    = '/usr/local/sphinx'; //no trailing slash
$config['Misc']['sphinx_config']    = $config['Misc']['sphinx_path'] . '/etc/vbulletin-sphinx.php';

保存并离开
:wq

 

 

-----------------------------------------------------------------
vbulletin-sphinx.php 上传到 /usr/local/sphinx/etc/ 目录
-----------------------------------------------------------------

vbulletin-sphinx.php 上传到 /usr/local/sphinx/etc/ 目录

在vBulletin 6.0 论坛程序.zip 的 do_not_upload 文件夹中,可找到vbulletin-sphinx.php

 

 

 

-----------------------------------------------------------------
创建 sphinxsearchfiles 文件夹
-----------------------------------------------------------------

进入宝塔面板

在 /www/wwwroot/域名.com/ ,创建 sphinxsearchfiles 文件夹

将vBulletin的sphinxsearchfiles文件夹中的几个文件,上传到此目录

在vBulletin 6.0 论坛程序.zip 的 do_not_upload 文件夹中,可找到 sphinxsearchfiles 文件夹与其数个文件

 

 

-----------------------------------------------------------------
修改 vbulletin-sphinx.php
-----------------------------------------------------------------


修改 vbulletin-sphinx.php
vi /usr/local/sphinx/etc/vbulletin-sphinx.php

 

改为宝塔面板用的 PHP 8.0 路径
#!/www/server/php/80/bin/php -q


 $myforumroot 更改为确切的论坛根目录
$myforumroot = '/www/wwwroot/你的域名.com';



$charsetTablesFolder = '/www/wwwroot/域名.com/sphinxsearchfiles';
$charsetTablesPrefix = 'sphinxcharsets_cjk.txt';



$utf8mb4 = true;



查找 mysql
能不能将 mysql 改为 mariadb,还需要测试过才知道

type    = mysql


listen    = {$config['Misc']['sphinx_port']}:mysql41




搜索 rt_attr_uint     = hasanswer
在这行底下添加

ngram_len        = 1

ngram_chars        = U+3000..U+2FA1F

 

保存并离开
:wq

 


-----------------------------------------------------------------
将 vbulletin-sphinx.php 文件设置为可执行文件
-----------------------------------------------------------------

chmod +x /usr/local/sphinx/etc/vbulletin-sphinx.php

 

 

 

 

-----------------------------------------------------------------
启动服务(daemon)
-----------------------------------------------------------------

cd /usr/local/sphinx/

/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/vbulletin-sphinx.php


忽略有关 vbulletin disk 索引的警告,一旦运行索引器就会创建
Sphinx2.png

 

 

 

如果有以下的错误,sphinx有地方配置错误了
Sphinx1.png

 

 

 

----------------------------------------------------------
测试sphinx是否运行
----------------------------------------------------------

ps ax | grep search[d]


如果正常运行,则显示 /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/vbulletin-sphinx.php 类似的消息

 

 


-----------------------------------------------------------------
论坛后台打开Sphinx中文搜索
-----------------------------------------------------------------

论坛后台 -> 设置 -> 选项 -> 消息搜索选项 -> 

启用搜索引擎 -> 是

搜索索引字的最小长度 -> 2

-> 保存

 

 

论坛后台 -> 设置 ->搜索类型

选择搜索执行 -> Sphinx搜索 -> 进行

 

 


论坛后台 -> 维护 -> 清除系统缓存

 

论坛后台 -> 维护 -> 一般更新工具 -> 重建搜索索引 -> 你确定要清空搜索索引? -> 是


论坛后台 -> 维护 -> 一般更新工具 -> 重建搜索索引 -> 要索引的内容类型 -> 所有 -> 重建搜索索引

 

本文章最後於,由Jack編輯

  • 樓主

网上找到开机启动Sphinx脚本

----------------------------------------------------------
reboot auto start sphinx
----------------------------------------------------------

写一个sphinx.sh

cd /usr/local/bin

vi sphinx.sh

将下面几行黏贴到 sphinx.sh

#!/bin/sh

. /etc/rc.d/init.d/functions

appName="Sphinx"

stop(){
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/vbulletin-sphinx.php --stop > /dev/null 2>&1
        ret=$?
        if [ $ret -eq 0 ]; then
            action $"Stoping $appName: " /bin/true
        else
            action $"Stoping $appName: " /bin/false
        fi
    return $ret
}  


start(){
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/vbulletin-sphinx.php > /dev/null 2>&1
        ret=$?
        if [ $ret -eq 0 ]; then
            action $"Starting $appName: " /bin/true
        else
            action $"Starting $appName: " /bin/false
        fi
    return $ret
}


case $1 in
    restart)
    stop
    start
    ;; 

    stop)
    stop
    ;;

    start)
    start
    ;; 
esac

exit 0


保存并离开
:wq

 

 

-----------------------------------------------------
sphinx.sh修改为可执行权限
-----------------------------------------------------

chmod +x /usr/local/bin/sphinx.sh

 

 

 

-----------------------------------------------------
修改rc.local,开机启动Sphinx
-----------------------------------------------------

之前写过 rc.local 教程,为了CentOS Linux 改为使用 iptables 防火墙 (开机启动 firewall.sh)

 

修改rc.local

vi /etc/rc.d/rc.local

 

把这一行 贴到 最底下

/usr/local/bin/sphinx.sh start


保存并离开
:wq

 

重开机
sudo reboot

 

测试sphinx是否运行
ps ax | grep search[d]


 

本文章最後於,由Jack編輯

建立帳號或登入後發表意見

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.