FastbuildAI宝塔手动安装部分教程
宝塔手动安装
宝塔面板通过软件商店安装的 PostgreSQL,默认不包含项目所需的 uuid-ossp
官方内置拓展。
另外还包括pgvector
、zhparser
等第三方拓展需要下载 PostgreSQL 官方完整源码包并编译安装。
1. 安装 PostgreSQL 官方内置拓展
下载源码(国内镜像源),此处以PostgreSQL 16.1版本举例
cd /tmp
# 阿里云镜像源
wget https://mirrors.aliyun.com/postgresql/source/v16.1/postgresql-16.1.tar.gz
# 或 清华大学镜像源
# wget https://mirrors.tuna.tsinghua.edu.cn/postgresql/source/v16.1/postgresql-16.1.tar.gz
解压源码
tar -zxvf postgresql-16.1.tar.gz
cd postgresql-16.1
编译安装(启用 uuid 支持)
# 这里的/www/server/pgsql是你宝塔安装的pgsql的目录,一般是/www/server/pgsql
./configure --prefix=/www/server/pgsql --with-uuid=e2fs
make && make install
编译所有官方内置拓展
cd contrib
make && make install
如果只需编译单个拓展,例如 uuid-ossp
:
cd contrib/uuid-ossp
make && make install
2. 安装第三方拓展
zhparser(中文分词)
cd /tmp
git clone https://github.com/amutu/zhparser.git
cd zhparser
make && make install
pgvector(向量搜索)
cd /tmp
git clone https://github.com/pgvector/pgvector.git
cd pgvector
make && make install
3. 激活拓展(统一在 fastbuild 数据库中执行)
切换到 psql 控制台
psql -U postgres -h localhost
创建 fastbuild 数据库(如果还没有)
CREATE DATABASE fastbuild OWNER fastbuildai;
切换到 fastbuild 数据库
\c fastbuild
激活需要的拓展
-- 官方内置拓展
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- 中文分词
CREATE EXTENSION IF NOT EXISTS zhparser;
-- 向量搜索
CREATE EXTENSION IF NOT EXISTS vector;
4. 给 fastbuildai 用户权限(防止权限不足报错)
GRANT ALL PRIVILEGES ON SCHEMA public TO fastbuildai;
ALTER DATABASE fastbuild OWNER TO fastbuildai;
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。