21
2025
03
01:11:58

Ubuntu环境下本地部署SearXNG

SearXNG部署日记


创建python虚拟环境

前置条件已经安装了conda

conda create --name searxng python=3.9

conda activate searxng

python版本至少3.9,之前使用python3.8报错

ERROR: Ignored the following versions that require a different python version: 3.1.0 Requires-Python >=3.9
ERROR: Could not find a version that satisfies the requirement flask==3.1.0 (from versions: 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.5.2, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.9, 0.10, 0.10.1, 0.11, 0.11.1, 0.12, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 3.0.0, 3.0.1, 3.0.2, 3.0.3)
ERROR: No matching distribution found for flask==3.1.0

下载searxng代码

cd /data

git clone https://github.com/searxng/searxng.git searxng

安装依赖

cd  searxng

pip install -r requirements.txt

配置SearXNG

编辑 searx/settings.yml 文件,

根据需求进行配置。

例如,你可以修改搜索引擎的默认设置、添加自定义搜索引擎等

后续更新这部分,先启动再说

启动SearXNG

python ./searx/webapp.py 
Traceback (most recent call last):
  File "/data/searxng/./searx/webapp.py", line 51, in <module>
    from searx.extended_types import sxng_request
ModuleNotFoundError: No module named 'searx'

发现报错,查看代码发现是目录问题

把webapp.py 复制到上级目录,重新执行,又报错

cp ./searx/webapp.py ./

python webapp.py 

ERROR:searx.webapp: server.secret_key is not changed. Please use something else instead of ultrasecretkey.

修改 server.secret_key:在 settings.yml 文件中找到 server.secret_key

 openssl rand -base64 32

生成字符串替换这一行


再次运行启动成功

Ubuntu环境下本地部署SearXNG


随便搜索,发现无法得到结果

Ubuntu环境下本地部署SearXNG


哎,,,,继续研究


继续研究发现:

searx/settings.yml 文件,

engines是所有支持的搜索引擎,默认很多都是禁用的,也就是  disabled: true

engines:
  - name: 360search
    engine: 360search
    shortcut: 360so
    disabled: true

  - name: 360search videos
    engine: 360search_videos
    shortcut: 360sov
    disabled: true

  - name: 9gag
    engine: 9gag
    shortcut: 9g
    disabled: true

  - name: adobe stock
    engine: adobe_stock
    shortcut: asi
    categories: ["images"]
    # https://docs.searxng.org/dev/engines/online/adobe_stock.html
    adobe_order: relevance
    adobe_content_types: ["photo", "illustration", "zip_vector", "template", "3d", "image"]
    timeout: 6
    disabled: true

  - name: adobe stock video
    engine: adobe_stock
    shortcut: asv
    network: adobe stock
    categories: ["videos"]
    adobe_order: relevance
    adobe_content_types: ["video"]
    timeout: 6
    disabled: true

  - name: adobe stock audio
    engine: adobe_stock
    shortcut: asa
    network: adobe stock
    categories: ["music"]
    adobe_order: relevance
    adobe_content_types: ["audio"]
    timeout: 6
    disabled: true

  - name: alexandria
    engine: json_engine
    shortcut: alx
    categories: general
    paging: true
    search_url: https://api.alexandria.org/?a=1&q={query}&p={pageno}
    results_query: results
    title_query: title
    url_query: url
    content_query: snippet
    timeout: 1.5
    disabled: true

批量修改文件,设置 disabled: true为 disabled: false

ps:更简单设置方法

打开主页,点击右上角设置按钮

Ubuntu环境下本地部署SearXNG

选择engnes

Ubuntu环境下本地部署SearXNG

把出现异常的搜索引擎停用,保留可以查询到结果的

点击保存


再次搜索

Ubuntu环境下本地部署SearXNG

哈哈,有结果了。

右侧很多是timeout或者error的搜索引擎,我们可以在searx/settings.yml 文件,把这部分给禁用。

再来一次搜索

Ubuntu环境下本地部署SearXNG

至此完成。

后面就把搜索集成到open-webui里




推荐本站淘宝优惠价购买喜欢的宝贝:

Ubuntu环境下本地部署SearXNG

本文链接:https://hqyman.cn/post/9549.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: