Chatgpt_web 部署
· 阅读需 1 分钟
部署 Chatgpt_web
系统:Ubuntu20.04
拉取源码:
git clone https://github.com/Chanzhaoyu/chatgpt-web.git
安装 node / pnpm
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# 验证
node -v
# 安装 pnpm
npm install pnpm -g
安装依赖
# 进入文件夹 /service 运行以下命令
pnpm install
# 根目录下运行以下命令
pnpm bootstrap
填写密钥
# service/.env 文件
# OpenAI API Key - https://platform.openai.com/overview
OPENAI_API_KEY=
# change this to an `accessToken` extracted from the ChatGPT site's `https://chat.openai.com/api/auth/session` response
OPENAI_ACCESS_TOKEN=
使用 systemd 管理应用
root@iZt4nbaxzkx16mx9901qpqZ:/etc/systemd/system# cat chatgpt.service
[Unit]
Description=chatgpt
[Service]
Type=simple
WorkingDirectory=/root/chatgpt-web-main
ExecStart=pnpm dev
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
root@iZt4nbaxzkx16mx9901qpqZ:/etc/systemd/system# cat chatgpt_api.service
[Unit]
Description=chatgpt_api
[Service]
Type=simple
WorkingDirectory=/root/chatgpt-web-main/service
ExecStart=pnpm start
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
启动应用
# 加载配置
systemctl daemon-reload
# 启动应用
systemctl start chatgpt_api.service
systemctl start chatgpt.service
# 设置开机自启
systemctl enable chatgpt_api.service
systemctl enable chatgpt.service