作者: 启鑫

  • Windows拆分映像

    在从无法容纳 Windows 映像文件大小的介质安装 Windows 时,可将 Windows 映像 (.wim) 文件拆分为一组较小的 (.swm) 文件,例如:

    • DVD(标准单面 DVD 存储 4.7GB)。
    • 格式化为 FAT32 的 U 盘。 FAT32 是启动许多新式(基于 UEFI 的)PC 所必需的,但它最大文件大小为 4GB。 (解决方法:创建具有多个分区的 U 盘。)

    限制

    • 无法修改一组拆分映像 (.swm) 文件。
    • 只有在所有 .swm 文件都在同一文件夹中时,才支持应用拆分的映像 (.swm) 文件。 这意味着,对于 DVD 部署,需要先将文件复制到目标 PC,然后才能使用 Windows 安装程序或 DISM/Apply-Image,如本主题中所示。

    拆分文件

    • 装载 Windows 安装介质。
    • 将 sources\install.wim 复制到本地 PC。 以下示例使用 G:\sources\install.wim 作为所复制文件的位置。
    • 拆分 Windows 映像:
    Dism /Split-Image /ImageFile:G:\sources\install.wim /SWMFile:J:\sources\install.swm /FileSize:4000

    其中:

    • G:\sources\install.wim 是要拆分的映像文件的名称和位置。
    • J:\sources\install.swm 是拆分的 .swm 文件的目标名称和位置。 第一个拆分的 .swm 文件将会被命名为 install.swm。 接下来的文件的文件名会带有数字,例如,install2.swm 文件、install3.swm 文件,等等。
    • 4000 是每个要创建的拆分 .swm 文件的最大大小(以 MB 为单位)。
    • 现在,J:\sources 文件夹中有一组 install.swm 文件。
  • Debian12安装 Immich 进行自托管照片和视频

    Immich 是一个强大的自托管照片和视频管理解决方案,允许用户在自己的服务器上存储、管理和浏览照片,同时提供智能搜索、面部识别等 AI 功能,保护您的隐私。

    1. 介绍 Immich

    Immich 的主要功能

    • 自动备份:支持手机和桌面端自动同步照片和视频。
    • 智能搜索:基于 AI 的搜索和标签功能,快速查找照片。
    • 面部识别:自动识别照片中的人物并进行分类。
    • 隐私保护:完全自托管,确保数据不会泄露到第三方服务器。
    • 高效存储:支持增量备份和重复数据删除,优化存储空间。
    • 跨平台支持:支持 Android、iOS、Web 和桌面端访问。

    2. 安装 Docker 和 Docker Compose

    在 Linux 服务器上运行以下命令安装 Docker:

    curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh

    安装完成后,检查 Docker 版本:

    docker --version

    安装 Docker Compose:

    apt install -y docker-compose

    3. 下载 Immich 并配置环境变量

    3.1 创建 Immich 安装目录

    mkdir ./immich-app && cd ./immich-app

    3.2 下载官方 Docker Compose 文件

    #  docker-compose.yml
    wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
    
    # .env
    wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env

    docker-compose.yml文件

    #
    # WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose
    #
    # Make sure to use the docker-compose.yml of the current release:
    #
    # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
    #
    # The compose file on main may not be compatible with the latest release.
    
    name: immich
    
    services:
      immich-server:
        container_name: immich_server
        image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
        # extends:
        #   file: hwaccel.transcoding.yml
        #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
        volumes:
          # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
          - ${UPLOAD_LOCATION}:/usr/src/app/upload
          - /etc/localtime:/etc/localtime:ro
        env_file:
          - .env
        ports:
          - '2283:2283'
        depends_on:
          - redis
          - database
        restart: always
        healthcheck:
          disable: false
    
      immich-machine-learning:
        container_name: immich_machine_learning
        # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
        # Example tag: ${IMMICH_VERSION:-release}-cuda
        image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
        # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
        #   file: hwaccel.ml.yml
        #   service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
        volumes:
          - model-cache:/cache
        env_file:
          - .env
        restart: always
        healthcheck:
          disable: false
    
      redis:
        container_name: immich_redis
        image: docker.io/redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8
        healthcheck:
          test: redis-cli ping || exit 1
        restart: always
    
      database:
        container_name: immich_postgres
        image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
        environment:
          POSTGRES_PASSWORD: ${DB_PASSWORD}
          POSTGRES_USER: ${DB_USERNAME}
          POSTGRES_DB: ${DB_DATABASE_NAME}
          POSTGRES_INITDB_ARGS: '--data-checksums'
        volumes:
          # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
          - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
        healthcheck:
          test: >-
            pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" || exit 1;
            Chksum="$$(psql --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" --tuples-only --no-align
            --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')";
            echo "checksum failure count is $$Chksum";
            [ "$$Chksum" = '0' ] || exit 1
          interval: 5m
          start_interval: 30s
          start_period: 5m
        command: >-
          postgres
          -c shared_preload_libraries=vectors.so
          -c 'search_path="$$user", public, vectors'
          -c logging_collector=on
          -c max_wal_size=2GB
          -c shared_buffers=512MB
          -c wal_compression=on
        restart: always
    
    volumes:
      model-cache:

    .env文件

    # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
    
    # The location where your uploaded files are stored
    UPLOAD_LOCATION=./library
    # The location where your database files are stored
    DB_DATA_LOCATION=./postgres
    
    # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
    # TZ=Etc/UTC
    
    # The Immich version to use. You can pin this to a specific version like "v1.71.0"
    IMMICH_VERSION=release
    
    # Connection secret for postgres. You should change it to a random password
    # Please use only the characters `A-Za-z0-9`, without special characters or spaces
    DB_PASSWORD=postgres
    
    # The values below this line do not need to be changed
    ###################################################################################
    DB_USERNAME=postgres
    DB_DATABASE_NAME=immich

    3.3 配置环境变量

    编辑 .env 文件:

    nano .env

    修改以下关键参数:

    # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
    
    # The location where your uploaded files are stored
    UPLOAD_LOCATION=./library
    # The location where your database files are stored
    DB_DATA_LOCATION=./postgres
    
    # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
    # TZ=Etc/UTC
    
    # The Immich version to use. You can pin this to a specific version like "v1.71.0"
    IMMICH_VERSION=release
    
    # Connection secret for postgres. You should change it to a random password
    # Please use only the characters `A-Za-z0-9`, without special characters or spaces
    DB_PASSWORD=postgres
    
    # The values below this line do not need to be changed
    ###################################################################################
    DB_USERNAME=postgres
    DB_DATABASE_NAME=immich
    • 指定备份存储位置:
      • 请在UPLOAD_LOCATION中填写您希望存储备份文件的绝对路径。建议选择服务器上具有足够可用空间的新建目录,以确保备份顺利进行。
    • 设置数据库密码:
      • 强烈建议您修改DB_PASSWORD,为其设置一个自定义的强密码。由于PostgreSQL服务仅在本地Docker容器内运行,此密码用于本地身份验证。为避免Docker在解析密码时出现问题,请仅使用A-Za-z0-9范围内的字符。您可以使用pwgen等工具生成安全的随机密码。

    4. 启动 Immich

    运行 Docker Compose 启动 Immich

    docker-compose.yml 所在目录运行:

    docker compose up -d

    5. 访问 Immich Web 界面

    在浏览器中输入:

    http://<服务器IP>:2283

    首次访问时,需要注册一个管理员账户,登录后即可开始使用。

  • WordPress 站点中添加 Google 搜索功能

    在 WordPress 站点中添加 Google 搜索功能

    尽管 WordPress 本身提供了搜索功能,但 Google 搜索能够提供更强大、更精准的结果,特别是当你希望在站内搜索时能够通过 Google 来过滤信息。这对于提升用户体验非常有用,尤其是在站点内容非常庞大的情况下。

    1. 添加 Google 搜索表单

    要在 WordPress 中添加 Google 搜索框,你只需要一个 HTML 表单,将搜索请求发送到 Google 的搜索页面。以下是实现这一功能的代码:

    <form action="https://www.google.com/search" method="get" target="_blank" style="display: flex; align-items: center; max-width: 500px; width: 100%; margin: 0 auto;">
        <input type="hidden" name="sitesearch" value="www.qixinlee.com"> <!-- 替换为你的网站 -->
        <input type="text" name="q" placeholder="输入搜索关键词" required style="padding: 14px 20px; font-size: 16px; width: 100%; border: 1px solid #ccc; border-radius: 3px; outline: none; margin-right: 10px;"> <!-- 增加右边距 -->
        <button type="submit" style="background-color: #333; border: none; color: white; cursor: pointer; padding: 8px 16px; font-size: 16px; border-radius: 3px;">
            通过 Google 进行搜索
        </button>
    </form>

    2. 将代码嵌入到你的 WordPress 站点

    将这段代码插入到你的 WordPress 站点的合适位置。

    使用自定义 HTML 小工具

    • 登录到 WordPress 后台,进入 外观 -> 编辑
    • 添加一个 自定义 HTML 小工具,并将代码粘贴进去。
    • 保存并发布,你的 Google 搜索框就会出现在页面上。

    通过添加一个简单的 Google 搜索表单,用户可以更方便地在你的 WordPress 站点上进行搜索。与默认的站内搜索相比,Google 搜索能够提供更准确和更快速的结果

  • 本地部署Gemma3,Ollama与Open WebUI部署教程详解

    Ollama部署Gemma3 模型并使用 Open WebUI 进行 Web 访问

    1. 安装 Ollama

    Ollama 是一个用于运行大型语言模型的工具。

    支持的操作系统

    • Windows
    • Linux
    • macOS

    下载和安装:

    2. 安装 Gemma3 模型

    Ollama 安装完成后,您可以使用以下命令下载并运行 Gemma3 模型。

    文本模型:

    • 1B 参数模型(32k 上下文窗口):
    ollama run gemma3:1b

    多模态模型(视觉):

    • 4B 参数模型(128k 上下文窗口):
    ollama run gemma3:4b
    • 12B 参数模型(128k 上下文窗口):
    ollama run gemma3:12b
    • 27B 参数模型(128k 上下文窗口):
    ollama run gemma3:27b
    • 运行上述命令之一将自动下载并启动相应的 Gemma3 模型。

    3. 安装 Open WebUI

    Open WebUI 提供了一个用户友好的 Web 界面,用于与 Ollama 运行的模型进行交互。

    使用 Conda 安装:

    1.创建 Conda 环境:

    conda create -n open-webui python=3.11
    1. 激活环境:
    conda activate open-webui
    1. 安装 Open WebUI:
    pip install open-webui
    1. 启动服务器:
    open-webui serve

    更新 Open WebUI:

    • 要将 Open WebUI 更新到最新版本,请运行:
    pip install -U open-webui

    4. 配置并启动 Open WebUI 以连接 Ollama

    访问 Open WebUI:

    • 安装完成后,在 Web 浏览器中访问以下地址:
    • http://localhost:8080/

    配置 Ollama 连接:

    • Open WebUI 应该会自动检测到本地运行的 Ollama 实例。
    • 如果需要手动配置,请在 Open WebUI 的设置中查找 Ollama 连接选项。
    • 确保 Open WebUI 已正确配置为使用您已安装的 Gemma3 模型。

    开始使用:

    • 现在,您可以使用 Open WebUI 的界面与 Gemma3 模型进行交互。您可以输入文本提示,并根据所选模型(文本或多模态)获得相应的响应。
  • Windows Server 更改远程桌面RDP 端口

    Windows Server 使用 PowerShell 更改 RDP 端口

    1. 检查当前 RDP 端口

    打开 PowerShell(以管理员身份运行)并执行以下命令:

    Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"

    此命令将显示当前 RDP 端口号(默认情况下为 3389)。

    显示输出

    PortNumber   : 3389
    PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations
    PSChildName  : RDP-Tcp
    PSDrive      : HKLM
    PSProvider   : Microsoft.PowerShell.Core\Registry

    2. 更改 RDP 端口

    运行以下命令,将 <port number> 替换为您希望使用的新端口号(例如 5000):

    $portvalue = <port number>
    
    Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue

    3. 创建防火墙规则以允许新端口

    如果没有相应的防火墙规则,新的 RDP 端口可能无法访问。运行以下命令,替换 <port number> 为您新设置的端口号:

    New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort <port number> 
    New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort <port number>

    4. 重启计算机

    更改端口后,必须 重启计算机 使更改生效。

  • Debian12为 history 命令添加时间戳显示

    1. 修改 ~/.bashrc 让 history 命令显示时间

    1. 编辑 ~/.bashrc 文件

    在终端执行以下命令,打开 ~/.bashrc 配置文件:

    nano ~/.bashrc
    1. 添加 HISTTIMEFORMAT 变量

    ~/.bashrc 文件末尾添加以下内容:

    # Histroy display time
    export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S  "

    这行代码的作用:

    • HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " —— 让 history 以 YYYY-MM-DD HH:MM:SS 的格式显示时间。

    如果你希望存储更多的历史命令,还可以添加:

    # 设置 history 命令记录的条数
    export HISTSIZE=10000
    export HISTFILESIZE=20000
    • HISTSIZE=10000 —— 设置 history 缓存 10,000 条命令(当前会话)。
    • HISTFILESIZE=20000 —— 让 .bash_history 文件最多存储 20,000 条记录。

    2. 使更改生效

    在终端执行以下命令,让 .bashrc 立即生效:

    source ~/.bashrc

    3. 测试

    执行 history 命令,检查是否显示时间:

    history

    如果输出结果前面出现了时间戳,说明已生效:

      1  2025-03-14 11:00:01  ls
      2  2025-03-14 11:05:32  ls