Ubuntu 22.04 Install deepseek
前言
deepseekAI助手。它具有聊天机器人功能,可以与用户进行自然语言交互,回答问题、提供建议和帮助解决问题。DeepSeek 的特点包括:
- 强大的语言理解能力:能够理解和生成自然语言,与用户进行流畅的对话。
- 多领域知识:涵盖科技、文化、历史等多个领域的知识,能够回答各种类型的问题。
- 持续学习:系统会不断学习和优化,提高回答的准确性和相关性。
- 安全隐私:注重用户数据的安全和隐私保护,遵守相关法律法规。
DeepSeek 旨在通过先进的人工智能技术,为用户提供高效、便捷的服务,提升工作和生活的效率。
创建一键部署deepseek自动化脚本
- 自动化脚本系统支持 Centos/Redhaht/RockyLinux/AlmaLinux/OracleLinux 8,9,10,ubuntu(20,22,24),debian(11,12),suse(12,15)
- ollama 命令文档,参考,参考2,参考3
- ollama download Windows,Linux,mac,所有下载
- deepseek Models 官网地址
- Chatbox 连接deepseek api工具,下载
- ollama 端口11434 需要自定义更改28行变量即可(28-32行环境变量需要自定义的更改)
- ollama 安装目录/opt/ollama
- deepseek 模型下载目录位置/opt/ollama/models
- ollama 服务位置/usr/lib/systemd/system/ollama.service
- 环境变量位置~/.bashrc
vim /deepseek_install.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2025/02/21<<!
# 系统支持 Centos/Redhaht/RockyLinux/AlmaLinux/OracleLinux 8,9,10,ubuntu(20,22,24),debian(11,12),suse(12,15)# ollama文档参考
https://github.com/ollama/ollama
https://ollama.readthedocs.io/quickstart/
https://ollama.cadn.net.cn/quickstart.html#google_vignette# ollama download
https://ollama.com/download/windows
https://ollama.com/download/mac
https://ollama.com/download/linux
https://github.com/ollama/ollama/releases#deepseek Models
https://ollama.com/library# download chatboxai
https://chatboxai.app/zh#download
!# variable
OLLAMA_PORT=11434
ollama_prefix=/opt/ollama
ollama_contents=ollama
ollama_models=models
opt_prefix=/opt# ollama download variable
ollama_url=https://github.com/ollama/ollama/releases/download/v0.5.11
ollama_tgz=ollama-linux-amd64.tgzinstall_basics() {# Check if the script is being run as root
if [ "$(id -u)" != "0" ]; thenecho "This script must be run as root."exit 1
fiif [[ -f /etc/os-release ]]; thenOS=$(cat /etc/*release* | grep "^ID=" | cut -d'=' -f2- | tr -d '"')VERSION=$(awk -F= '/VERSION_ID/{print $2}' /etc/os-release | tr -d '"') #VERSION=$( grep -oE 'VERSION_ID="[^"]+"' /etc/os-release | cut -d'"' -f2) elseecho -e "\033[31mThis script only supports $OS $VERSION...\033[0m"exit 1
fi# Check the ollama version
if ! [ -d "$ollama_prefix" ]; thenecho -e "\033[32m Installing ollama for $OS $VERSION...\033[0m"case $VERSION in# CentOS/RedHat/oracle/RockLinux/AlmaLinux 8 install 8|8.1|8.2|8.3|8.4|8.5|8.6|8.7|8.8|8.9|8.10)echo Installing basics...yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpmyum install -y net-tools wget curlecho "firewall prometheus port config"firewall_port_up# install ollamainstall_ollama;;# CentOS/RedHat/oracle/RockLinux/AlmaLinux 9 install9.0|9.1|9.2|9.3|9.4|9.5|9.6|9.7|9.8|9.9|9.10) echo Installing basics...yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpmyum install -y net-tools wget curlecho "firewall prometheus port config"firewall_port_up# install ollamainstall_ollama;;# CentOS/RedHat/oracle/RockLinux/AlmaLinux 10 install10.0|10.1|10.2|10.2|10.3|10.4|10.5|10.6|10.7|10.8|10.9|10.10) echo Installing basics...yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpmyum install -y net-tools wget curlecho "firewall prometheus port config"firewall_port_up# install ollamainstall_ollama;;# openEuler 20,22,23,24 Linux install20.03|22.03|23.03|24.03) echo "add epel repo"openEuler_epel_repoecho "firewall prometheus port config"firewall_port_upecho Installing basics...yum install -y net-tools wget curl# install ollamainstall_ollama;;# ubuntu 20,21,22,23,24 Linux install20.04|21.04|22.04|23.04|24.04)echo "Disable system standby"systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.targetecho "Pop-up block"sed -i '$ a\export DEBIAN_FRONTEND=noninteractive' /etc/profilesource /etc/profileecho "install Base Package"apt-get updateapt-get install -y firewalld curl net-tools vimapt-get install -y git wgetecho "firewall prometheus port config"firewall_port_up# install ollamainstall_ollama;;# Debian 10,11.1210|11|12)echo "Disable system standby"systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.targetecho "Pop-up block"sed -i '$ a\export DEBIAN_FRONTEND=noninteractive' /etc/profilesource /etc/profileecho "install Base Package"apt-get updateapt-get install -y firewalld curl net-tools vimapt-get install -y git wget# install ollamainstall_ollama;;# SUSE 12 install12.?)echo Installing basics...SUSEConnect -p sle-sdk/12.5/x86_64zypper in -y curl net-toolsecho "firewall sql server port"sed -i '/^FW_SERVICES_EXT_TCP=/ s/"\(.*\)"/"\1 '$OLLAMA_PORT'"/' /etc/sysconfig/SuSEfirewall2systemctl restart SuSEfirewall2.service# install ollamainstall_ollama;;# SUSE 15 install15.?)echo Installing basics...zypper install -y net-tools net-tools-deprecatedrpm -ivh https://ftp.lysator.liu.se/pub/opensuse/distribution/leap/15.6/repo/oss/x86_64/net-tools-deprecated-2.0+git20170221.479bb4a-3.11.x86_64.rpmzypper in -y firewalld curl echo "firewall ollama port config"firewall_port_up# install ollamainstall_ollama;;*)echo -e "\033[31m Unsupported $OS $VERSION...\033[0m" exit 1;;
esacecho -e "\033[32m ollama for $OS $VERSION successfully installed...\033[0m"
elseecho -e "\033[33m ollama for $OS $VERSION already installed...\033[0m"
fi}# Obtain the system version number
VERSION_ID=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d'=' -f2 | tr -d '"')# openEuler 20.03 22.03 23.03 24.03 add epel 8,9
openEuler_epel_repo (){if [[ $VERSION_ID =~ ^2[2-4]\.03$ ]]; thenrepo_version=9
elif [[ $VERSION_ID == 20.03 ]]; thenrepo_version=8
fiecho "openEuler add epel repo"
cat <<EOF>>/etc/yum.repos.d/epel.repo
[epel]
name=epel
baseurl=https://dl.fedoraproject.org/pub/epel/${repo_version}/Everything/x86_64/
enabled=1
gpgcheck=0
priority=1
EOF
}# firewall port up
firewall_port_up (){
echo "firewall ollama port"
systemctl enable --now firewalld
firewall-cmd --zone=public --add-port=$OLLAMA_PORT/tcp --permanent && firewall-cmd --reload
}# install ollama
install_ollama (){echo "download ollama"
wget -N -P $opt_prefix $ollama_url/$ollama_tgzecho "Unzip installation ollama"
mkdir -p $opt_prefix/{$ollama_contents,$ollama_models}
tar -zxf $opt_prefix/$ollama_tgz -C $ollama_prefix
rm -rf $opt_prefix/$ollama_tgzecho "ollama environment variable"
echo 'export PATH='$ollama_prefix'/bin:$PATH' >> ~/.bashrc
echo 'export PATH='$ollama_prefix'/lib:$PATH' >> ~/.bashrc
echo 'export OLLAMA_HOST=0.0.0.0:'$OLLAMA_PORT'' >> ~/.bashrc
source ~/.bashrcecho "create ollama server"
cat <<EOF>>/usr/lib/systemd/system/ollama.service
[Unit]
Description=Ollama Service
After=network-online.target[Service]
Environment="OLLAMA_HOST=0.0.0.0:$OLLAMA_PORT"
Environment="OLLAMA_ORIGINS=*"
Environment="OLLAMA_MODELS=$ollama_prefix/models"
ExecStart=$ollama_prefix/bin/ollama serve
User=root
Group=root
Restart=always
RestartSec=3[Install]
WantedBy=default.target
EOFecho "start ollama"
systemctl daemon-reload
systemctl start ollama
systemctl enable ollamaecho "download deepseek model"
$ollama_prefix/bin/ollama run deepseek-r1:8b
}main (){install_basics
}main
执行一键部署deepseek
- ln -sf bash /bin/sh 切换bash
bash /deepseek_install.sh
ollama api访问接口测试
- 正式环境不要对外开放
chatbox 连接deepseek
- chatbox 下载,有很多的你也可以尝试使用其它的方式接入
- 模型提供方ollama api
- api 域名你的主机IP和端口
- 模型,你部署的模型选择