搭建chatgpt

搭建过程比较简单,首先用ssh根据连接自己的服务器,然后

1.安装docker环境:

1
apt update && apt install docker.io -y

2.拉取pandora镜像

1
docker pull yidadaa/chatgpt-next-web

3.启动容器

这里设置的端口是3000,也可以自己改成其他端口

1
2
3
4
docker run -d -p 3000:3000 \
-e OPENAI_API_KEY=sk-xxxx \
-e CODE=your-password \
yidadaa/chatgpt-next-web

这里推荐使用国内中转网站https://api.chatanywhere.tech,API_KEY可以在https://github.com/chatanywhere/GPT_API_free?tab=readme-ov-file中申请。

1
2
3
4
5
docker run -d -p 3000:3000 \
-e OPENAI_API_KEY=sk-xxxx \
-e CODE=your-password \
-e BASE_URL=https://api.chatanywhere.tech \
yidadaa/chatgpt-next-web

然后打开你用到的端口

1
ufw allow 3000

这里以3000为例,如果你用的是其他端口就改成其他的,然后reboot重启服务器即可。

然后需要到云服务器端开启安全组的对应端口。

之后在浏览器输入你的服务器ip加’ : ‘加端口号就可以进入登录界面了,可以用账号密码登录。

绑定域名

如果不想用ip访问,可以买一个域名,然后使用nginx反代。

1.安装nginx

1
apt install nginx

2.设置反向代理

/etc/nginx/nginx.conf里面的http里面加上

1
2
3
4
5
6
7
8
server {
listen 80;
server_name 你的域名;

location / {
proxy_pass http://127.0.0.1:3000;
}
}

然后就可以通过域名直接访问了。