linux云服务器安装了ollama,配置公网ip来访问教程
·
完整配置步骤
1.修改 Ollama 监听地址
# 设置 Ollama 监听所有网络接口(包括公网)
export OLLAMA_HOST="0.0.0.0:11434" # Linux/macOS
# 对于 Windows:
set OLLAMA_HOST=0.0.0.0:11434 # CMD
$env:OLLAMA_HOST="0.0.0.0:11434" # PowerShell
# 永久生效(Linux/macOS):
echo 'export OLLAMA_HOST="0.0.0.0:11434"' >> ~/.bashrc
source ~/.bashrc
2. 重启 Ollama 服务
# 停止并重新启动服务
ollama stop
ollama serve &
3. 配置云服务器防火墙
-
安全组规则(在云服务商控制台配置):
-
允许入站:TCP 端口 11434
-
源IP:
0.0.0.0/0(或指定IP范围更安全)
-
-
系统防火墙
-
# Ubuntu/Debian sudo ufw allow 11434/tcp sudo ufw reload # CentOS/RHEL sudo firewall-cmd --permanent --add-port=11434/tcp sudo firewall-cmd --reload
4. 验证本地监听
netstat -tuln | grep 11434
5. 测试公网访问(从本地机器)
curl http://<云服务器公网IP>:11434/api/tags
更多推荐
所有评论(0)