Open main menu
首页
专栏
课程
分类
归档
Chat
Sci-Hub
谷歌学术
Libgen
GitHub镜像
登录/注册
搜索
搜索
关闭
Previous
Previous
Next
Next
【详细教程】国内部署ChatGPT镜像网站
sockstack
/
909
/
2023-11-07 00:01:40
<p><span style="color: red; font-size: 18px">ChatGPT 可用网址,仅供交流学习使用,如对您有所帮助,请收藏并推荐给需要的朋友。</span><br><a href="https://ckai.xyz/?sockstack§ion=detail" target="__blank">https://ckai.xyz</a><br><br></p> <article class="baidu_pl"><div id="article_content" class="article_content clearfix"> <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css"> <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-25cebea3f9.css"> <div id="content_views" class="markdown_views prism-atom-one-dark"> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg><p></p> <div class="toc"> <h3>文章目录</h3> <ul><li> <ul> <li>一、准备阶段</li> <li> <ul> <li>0、注册Open AI账号</li> <li>1、创建API密钥</li> <li>2、国内云服务器</li> <li>3、国外云服务器</li> <li>4、镜像网站代码</li> <li>5、效果</li> <li>`重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照`</li> <li>`重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照`</li> <li>`重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照`</li> </ul> </li> <li>二、开始部署</li> <li> <ul> <li>1、部署HTTP代理</li> <li>2、安装nodejs环境</li> <li>3、安装pnpm</li> <li>4、更新make、gcc、g++</li> <li>5、安装Docker</li> <li>6、部署镜像网站</li> <li>7、使用反向代理部署网站</li> </ul> </li> </ul> </li></ul> </div> <p></p> <h2> <a id="_1"></a>一、准备阶段</h2> <p>国内云服务器主要用来部署镜像网站,,国外服务器主要用来部署HTTP/HTTPS代理,因为<code>目前国内环境访问Open AI的API服务器会有问题</code>,所以最好有一个在美国的服务器,部署完成后就能达到快速访问ChatGPT的效果。</p> <h3> <a id="0Open_AI_4"></a>0、注册Open AI账号</h3> <p>参考链接:教程:在国内如何注册OpenAI账号并试用ChatGPT</p> <h3> <a id="1API_7"></a>1、创建API密钥</h3> <p>参考链接:如何在OpenAI创建一个api key</p> <h3> <a id="2_9"></a>2、国内云服务器</h3> <p>链接:【Tencent云服务器】</p> <h3> <a id="3_12"></a>3、国外云服务器</h3> <p>V-u-l-t-r-服务器有些新地区刚开比较划算,性能基本能满足搭建梯子和HTTP代理</p> <h3> <a id="4_14"></a>4、镜像网站代码</h3> <p>GitHub地址:chatgpt-mirror<br> 蓝奏云:https://wwvb.lanzout.com/ik7Wy0tbx1vg 密码:ccng</p> <h3> <a id="5_19"></a>5、效果</h3> <p>我是使用自己的域名部署了一个网站,可以直接在浏览器输入网址后访问,这里就不放出来了,因为我这种部署方式用的是自己的API密钥,目前免费额度只有5$ ,太多人用很快就没了,你们可以用自己的API key,这个会在后面讲到!!![/狗头保命]<br> <img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/b466cc1eff164f3fa64ca1460c9aecdf.gif" alt="请添加图片描述"></p> <hr> <h3> <a id="glibc_25"></a><code>重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照</code> </h3> <h3> <a id="glibc_26"></a><code>重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照</code> </h3> <h3> <a id="glibc_27"></a><code>重要:部署时会修改glibc库,为了防止云服务器被搞坏,请提前进行备份或者创建快照</code> </h3> <h2> <a id="_28"></a>二、开始部署</h2> <h3> <a id="1HTTP_29"></a>1、部署HTTP代理</h3> <p><code>在Vultr服务器上部署代理</code></p> <pre><code class="prism language-bash">yum <span class="token function">install</span> tinyproxy<span class="token comment"># 修改配置文件</span> <span class="token comment"># 可以修改listen的IP还有监听的端口</span> <span class="token function">vim</span> /etc/tinyproxy/tinyproxy.conf<span class="token comment"># 启动 </span> systemctl start tinyproxy <span class="token comment"># 开机自启 </span> systemctl <span class="token builtin class-name">enable</span> tinyproxy </code></pre> <h3> <a id="2nodejs_44"></a>2、安装nodejs环境</h3> <p><code>在云服务器上部署</code><br> 该项目明确表明需要用到<code>Node.js 18.x</code><br> 否则构建时会出现问题<br> <img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/4058bbd9b1ae4afb8cf3c691cf7fb0d9.png" alt="请添加图片描述"></p> <p><code>因为系统中不同的项目可能需要不同的Node.js版本,为了方便管理,安装nvm</code></p> <pre><code class="prism language-bash"><span class="token comment"># nvm允许您通过命令行快速安装和使用不同版本的node</span><span class="token comment"># 安装脚本:</span> <span class="token function">curl</span> -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh <span class="token operator">|</span> <span class="token function">bash</span><span class="token comment"># 运行上述命令下载脚本并运行它。该脚本将 nvm 存储库克隆到~/.nvm,并尝试将下面代码段中的源代码行添加到正确的配置文件(~/.bash_profile、~/.zshrc、~/.profile或~/.bashrc)。</span><span class="token comment"># 使配置生效</span> <span class="token builtin class-name">source</span> .bashrc验证:a:nvm ls-remote查看所有可安装的node版本号b:nvm <span class="token function">install</span> <span class="token number">13.0</span>.0安装13.0.0版本的nodec:nvm <span class="token function">install</span> <span class="token number">15</span>安装15系列中最高版本的node比如15系列有15.0.0, <span class="token number">15.0</span>.1, <span class="token number">15.1</span>.1, <span class="token number">15.1</span>.2, <span class="token number">15.2</span>.1, <span class="token number">15.3</span>.0,那么最后安装的就是15.3.0d:nvm <span class="token function">install</span> <span class="token number">14.2</span>安装14.2系列中最高版本的nodee:nvm list查看已安装的所有node版本以及默认的版本f:nvm use <span class="token number">13.0</span>.0使用13.0.0版本的nodeg:nvm use <span class="token number">14.2</span>使用14.2系列的最高版本nodeh:nvm uninstall <span class="token number">13.0</span>.0卸载13.0.0版本的node<span class="token comment"># 安装对应版本node.js</span> nvm ls-remote nvm <span class="token function">install</span> v18.16.0 </code></pre> <p><img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/aa910cee4efe42acab03b52f03a6b09c.png" alt="请添加图片描述"></p> <h3> <a id="3pnpm_87"></a>3、安装pnpm</h3> <p>安装好nvm和nodejs后</p> <pre><code class="prism language-bash"><span class="token comment"># 版本切换</span> nvm use <span class="token number">18.16</span>.0<span class="token comment"># 安装pnpm</span> <span class="token function">npm</span> <span class="token function">install</span> <span class="token function">pnpm</span> -g<span class="token comment"># 环境验证</span> nvm list <span class="token function">node</span> -v <span class="token function">npm</span> -v <span class="token function">pnpm</span> -v </code></pre> <p><img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/da7bb463a8d9464599b2cdcdf6df81f9.png" alt="请添加图片描述"></p> <h3> <a id="4makegccg_103"></a>4、更新make、gcc、g++</h3> <p>在上述步骤中会出现一些报错,例</p> <pre><code class="prism language-bash">node: /lib64/libm.so.6: version <span class="token variable"><span class="token variable">`</span>GLIBC_2.27' not found <span class="token punctuation">(</span>required by <span class="token function">node</span><span class="token punctuation">)</span> node: /lib64/libc.so.6: version <span class="token variable">`</span></span>GLIBC_2.25<span class="token string">' not found (required by node) node: /lib64/libc.so.6: version `GLIBC_2.28'</span> not found <span class="token punctuation">(</span>required by <span class="token function">node</span><span class="token punctuation">)</span> node: /lib64/libstdc++.so.6: version <span class="token variable"><span class="token variable">`</span>CXXABI_1.3.9' not found <span class="token punctuation">(</span>required by <span class="token function">node</span><span class="token punctuation">)</span> node: /lib64/libstdc++.so.6: version <span class="token variable">`</span></span>GLIBCXX_3.4.20<span class="token string">' not found (required by node) node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21'</span> not found <span class="token punctuation">(</span>required by <span class="token function">node</span><span class="token punctuation">)</span> </code></pre> <p>这是因为node.js 18.0依赖与高版本的glibc库,所以需要进行更新,从报错可知,我需要的最高版本为<code>GLIBC_2.28</code>,所有我需要安装这个版本</p> <p><code>先更新gcc与g++,最新版的也不兼容,需要下载gcc-8.2.0</code></p> <pre><code class="prism language-bash"><span class="token comment"># 安装make</span> <span class="token function">wget</span> http://ftp.gnu.org/pub/gnu/make/make-4.3.tar.gz <span class="token function">tar</span> -zxvf make-4.3.tar.gz <span class="token builtin class-name">cd</span> make-4.3 ./configure --prefix<span class="token operator">=</span>/usr <span class="token builtin class-name">type</span> <span class="token function">make</span> <span class="token function">make</span> check <span class="token function">make</span> <span class="token function">install</span><span class="token comment"># 安装gcc、g++ </span> <span class="token function">wget</span> https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz <span class="token function">tar</span> -zxvf gcc-8.2.0.tar.gz <span class="token builtin class-name">cd</span> gcc-8.2.0 <span class="token comment"># 下载gmp mpfr mpc等供编译需求的依赖项 </span> ./contrib/download_prerequisites<span class="token comment"># 配置 </span> <span class="token function">mkdir</span> build <span class="token builtin class-name">cd</span> build <span class="token punctuation">..</span>/configure --prefix<span class="token operator">=</span>/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking<span class="token operator">=</span>release --enable-languages<span class="token operator">=</span>c,c++ --disable-multilib <span class="token comment"># 编译安装 需要很久很久很久</span> <span class="token function">make</span> -j <span class="token number">2</span> <span class="token function">make</span> <span class="token function">install</span> </code></pre> <p><code>更新glibc库</code></p> <pre><code class="prism language-bash"><span class="token function">wget</span> http://ftp.gnu.org/pub/gnu/glibc/glibc-2.28.tar.gz <span class="token function">tar</span> -zxvf glibc-2.28.tar.gz <span class="token builtin class-name">cd</span> glibc-2.28/ <span class="token function">mkdir</span> build <span class="token builtin class-name">cd</span> build <span class="token punctuation">..</span>/configure --prefix<span class="token operator">=</span>/usr --disable-profile --enable-add-ons --with-headers<span class="token operator">=</span>/usr/include --with-binutils<span class="token operator">=</span>/usr/bin<span class="token function">make</span> <span class="token operator">&&</span> <span class="token function">make</span> <span class="token function">install</span><span class="token comment"># 查看文件软链接</span> <span class="token function">ls</span> -l /lib64/libc.so.6 <span class="token comment"># 再次查看系统中可使用的glibc版本 </span> strings /lib64/libc.so.6 <span class="token operator">|</span><span class="token function">grep</span> GLIBC_ strings /usr/local/gcc-8.2.0/lib64/libstdc++.so.6 <span class="token operator">|</span> <span class="token function">grep</span> GLIBCXX_<span class="token comment"># 升级GLIBCXX</span> <span class="token builtin class-name">cd</span> /usr/local/gcc-8.2.0/lib64 strings ./libstdc++.so.6 <span class="token operator">|</span><span class="token function">grep</span> GLIBCXX_<span class="token function">cp</span> libstdc++.so.6.0.25 /usr/lib64/<span class="token comment"># 重新链接libstdc++.so.6</span> <span class="token builtin class-name">cd</span> /usr/lib64/ <span class="token function">rm</span> libstdc++.so.6 -f <span class="token function">ln</span> -s ./libstdc++.so.6.0.25 ./libstdc++.so.6<span class="token comment"># 查看可用版本</span> strings /lib64/libstdc++.so.6 <span class="token operator">|</span><span class="token function">grep</span> GLIBCXX_ </code></pre> <h3> <a id="5Docker_179"></a>5、安装Docker</h3> <p>因为我采用的是用docker容器的方式部署,所以需要安装docker</p> <pre><code class="prism language-bash"><span class="token builtin class-name">cd</span> /etc/yum.repos.d/ <span class="token function">wget</span> https://download.docker.com/linux/centos/docker-ce.repo yum list docker-ce --showduplicates <span class="token operator">|</span> <span class="token function">sort</span> -ryum <span class="token function">install</span> docker-ce-18.06.3.ce-3.el7 -y<span class="token comment"># 启动docker服务</span> systemctl start <span class="token function">docker</span><span class="token comment"># 设置docker服务开机自启</span> systemctl <span class="token builtin class-name">enable</span> <span class="token function">docker</span> </code></pre> <h3> <a id="6_196"></a>6、部署镜像网站</h3> <pre><code class="prism language-bash"><span class="token function">git</span> clone https://github.com/yuezk/chatgpt-mirror.git<span class="token builtin class-name">cd</span> chatgpt-mirror<span class="token comment"># 新建一个 .env 文件,输入 OPENAI_API_KEY:使用自己申请的API密钥</span> <span class="token assign-left variable">OPENAI_API_KEY</span><span class="token operator">=</span>sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <span class="token comment"># optional, support http or socks proxy</span> <span class="token comment"># 代理配置</span> <span class="token assign-left variable">HTTP_PROXY</span><span class="token operator">=</span>http://proxy-server-ip:port<span class="token comment"># 构建镜像</span> $ <span class="token function">docker</span> build -t chatgpt-mirror <span class="token builtin class-name">.</span><span class="token comment"># 运行容器</span> <span class="token function">docker</span> run -itd -p <span class="token number">0.0</span>.0.0:3000:3000 --name chatgpt -h chatgpt -m 1024m --cpus<span class="token operator">=</span><span class="token number">1</span> --env-file .env chatgpt-mirror </code></pre> <p>此时输入<code>http://IP:3000</code>便可以访问网址,记得在云服务器管理后台开放该端口</p> <h3> <a id="7_217"></a>7、使用反向代理部署网站</h3> <p>此时可以将之前创建的容器进行删除,同时云服务器那边只需要开发<code>80</code>和<code>443</code>端口</p> <pre><code class="prism language-bash"><span class="token function">docker</span> stop chatgpt <span class="token operator">&&</span> <span class="token function">docker</span> <span class="token function">rm</span> chatgpt<span class="token comment"># 启动容器</span> <span class="token function">docker</span> run -itd -p <span class="token number">127.0</span>.0.1:3000:3000 --name chatgpt -h chatgpt -m 1024m --cpus<span class="token operator">=</span><span class="token number">1</span> --env-file .env chatgpt-mirror </code></pre> <p>使用宝塔后台添加网站<img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/43739f3f341b4cab9cd4302da73f67c1.png" alt="请添加图片描述"><br> 添加反向代理<br> <img referrerpolicy="no-referrer" src="https://img-blog.csdnimg.cn/99bd6d07059b43598e5ae63b4842b169.png" alt="在这里插入图片描述"><br> 此时直接访问配置好的域名便可访问镜像网站。</p> </div> <link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/markdown_views-98b95bb57c.css" rel="stylesheet"> <link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/style-c216769e99.css" rel="stylesheet"> </div> <div id="treeSkill"></div> </article>
【详细教程】国内部署ChatGPT镜像网站
作者
sockstack
许可协议
CC BY 4.0
发布于
2023-11-07
修改于
2024-10-03
上一篇:软件:常用 Linux 软件汇总,值得收藏
下一篇:chatgpt赋能python:Python处理雷达数据
尚未登录
登录 / 注册
文章分类
博客重构之路
5
Spring Boot简单入门
4
k8s 入门教程
0
MySQL 知识
1
NSQ 消息队列
0
ThinkPHP5 源码分析
5
使用 Docker 从零开始搭建私人代码仓库
3
日常开发汇总
3
标签列表
springboot
hyperf
swoole
webman
php
多线程
数据结构
docker
k8s
thinkphp
mysql
tailwindcss
flowbite
css
前端