不知道你有沒有遇到這個問題,當你使用ChatGPT聊得正開心或是問題就快要解決時,結果跳出:「您的 GPT-4o 已達到上限。由於包含附件,您需要 GPT-4o 才能繼續此聊天。」就因為你上傳了檔案附件,你就被強制暫停對話了……,於是我就想架設「自己的ChatGPT」,上網查資料發現一年前就有非常多人分享Ollama搭配Open WebUI 介面來和大語言模型(LLM)互動。
Ollama 核心是將大型語言模型(LLM)透過輕量且高效的推理框架,在本地電腦上執行。它通常利用開源模型(例如 LLaMA)經過特別格式轉換與優化,搭配底層推理引擎如 GGML,讓模型能在沒有強大雲端硬體的情況下也能快速推論。
在這個系統中,Ollama 可以視為負責運行大型語言模型(LLM)的核心引擎,它在本地電腦上執行模型推理。而 Open WebUI 則扮演前端介面的角色,透過網頁提供使用者直覺的聊天視窗和管理工具,方便用戶與 Ollama 後端的模型進行互動,包括對話紀錄管理、參數調整等功能。兩者結合,打造出一套既強大又易用的本地 AI 使用體驗。
整套都是開源的,而且就算用老顯卡也能跑小的模型,非常符合我現在的情境,我的Ubuntu Server就裝著GTX 960 4G,於是確認可行就開始架設。

先安裝OIlama
P.S. 如果想要GPU加速(尤其是Nvidia),要確保電腦有安裝驅動和CUDA
執行官方安裝腳本:
curl -fsSL https://ollama.com/install.sh | sh
確認Ollama 運行狀態:
sudo systemctl status ollama
測試Ollama 運作
Ollama 官方模型庫: https://ollama.com/search
這邊可以查發布在官方的各種模型,先選一個下載試試
我這邊以qwen3:4b舉例,先不要選參數量太高的模型:
ollama pull qwen3:4b
接下來執行Ollama:
ollama run qwen3:4b
他會載入模型,完成後就可以對話
user@ubuntuserver:~$ ollama run qwen3:4b
>>> Send a message (/? for help)
對話一下:
>>> who are you?
Thinking...
Okay, the user is asking "who are you?" I need to explain who I am in a clear and friendly way. Let me start by
stating my name, Qwen. Then, mention that I'm a large language model developed by Alibaba Cloud. I should
highlight my capabilities, like answering questions, creating content, and helping with various tasks. Also, it's
important to note that I'm designed to be helpful and safe, following the guidelines set by Alibaba Cloud. I
should make sure the response is concise but covers all the key points. Let me check if I need to mention
anything else, like the different versions or specific features, but maybe that's too detailed. Keep it simple
and welcoming. Alright, that should cover it.
...done thinking.
Hello! I am Qwen, a large language model developed by Alibaba Cloud. I can help with answering questions,
creating content, and assisting with various tasks. I'm designed to be helpful, safe, and friendly. How can I
assist you today? 😊
>>> Send a message (/? for help)
看來已經正常運作,我們就可以安裝Open WebUI了!
安裝Open WebUI
這次Open WebUI安裝我打算安裝在Docker容器中,所以要先安裝Docker,也可以多安裝Docker Compose
sudo apt install -y docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
newgrp docker
先下載最新映像:
docker pull ghcr.io/open-webui/open-webui:latest
用指令啟動Docker:
docker run -d --name open-webui \
-p 3000:3000 \
-e OPENWEBUI_BACKEND_URL=http://localhost:8080 \
ghcr.io/open-webui/open-webui:latest
或是用docker-compose啟動,寫配置檔在open-webu目錄:
mkdir -p ~/open-webui
cd open-webui
vi ~/open-webui/docker-compose.yml
version: '3'
services:
openwebui:
image: ghcr.io/open-webui/open-webui:latest
ports:
- "8080:8080"
volumes:
- ./models:/app/models
restart: unless-stopped
docker-compose up -d
然後在瀏覽器輸入:
http://server_ip:8080
沒意外應該會跑出這個頁面

註冊就可以開始用了!
初始設定
需要先連線到剛剛建好的Ollama Server,也就是
https://localhost:11434
並記得在防火牆(iptables或ufw)允許流量,

連上後就可以透過Open WebUI更方便下載模型,然後就可以到New Chat和模型對話

Open WebUI還有更進階的應用,像是網頁搜尋、RAG、文件搜索、知識庫、工具、函式等,我自己都還沒探索完全
參考資料
https://ivonblog.com/posts/ollama-llm
https://ivonblog.com/posts/ollama-llm-docker/
https://ithelp.ithome.com.tw/articles/10348913