1.首先安装python3环境,不同的系统可能命令有所区别
#更新
sudo apt update
sudo apt upgrade
# 安装依赖
sudo apt install software-properties-common
# 添加 deadsnakes PPA 源
sudo add-apt-repository ppa:deadsnakes/ppa
#安装python
sudo apt install python3
python3 --version
sudo apt install python3-pip
pip3 --version
2.安装python虚拟环境
sudo apt install python3-venv
3.上传chatgpt-web-main.tar.gz,解压并进入到chatgpt-web-main目录
4.创建虚拟环境:
python3 -m venv newchat.env
5.进入虚拟环境
source /opt/chat/chatgpt-web-main/newchat.env/bin/activate
6.配置chatgpt-web-main应用中的openAi key,启动服务:
python3.10 /opt/chat/chatgpt-web-main/main.py
nohup python3.10 /opt/chat/chatgpt-web-main/main.py &
7.配置nginx文件:
server {
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name chat.***.xyz;
ssl_certificate /root/.acme.sh/chat.***.xyz_ecc/chat.***.xyz.cer;
ssl_certificate_key /root/.acme.sh/chat.***.xyz_ecc/chat.***.xyz.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_session_cache builtin:1000 shared:SSL:10m;
proxy_buffering off;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:8184/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
其中proxy_buffering off; 表示打字机效果,不加此行代码无打字机效果,等待输出结果之后一次性返回结果。