Header

How to Install DeepSeek on Your Cloud Server with Ollama LLM

AI, Launches, Open Source, Python, and Tutorials

Post Image

Running large language models like DeepSeek on your cloud server or VPS is a powerful way to explore AI capabilities while maintaining control over your infrastructure. This guide will walk you through installing DeepSeek using Ollama on a cloud-hosted Ubuntu 24.04 instance, setting up automated deployments with DeployHQ, and configuring a Web UI for remote access.

What is DeepSeek, Ollama, and DeployHQ?

  • DeepSeek: An advanced AI model designed for natural language processing tasks like answering questions, generating text, and more.

  • Ollama: A platform that simplifies running large language models on your server by providing tools to manage and interact with models like DeepSeek. More here.

  • DeployHQ: A deployment automation platform that integrates with Git repositories to manage and automate deployments across different environments.

  • Web UI: A graphical interface that allows you to interact with DeepSeek through your browser from anywhere.

Prerequisites

Before we begin, make sure you have:

  • A VPS or cloud instance running Ubuntu 24.04
  • Root or sudo access to your server
  • At least 16GB of RAM (32GB recommended for production use)
  • Domain name (optional but recommended)
  • Git account
  • DeployHQ account
  • Basic understanding of server administration

Step 1: Initial Server Setup

First, connect to your VPS/cloud server via SSH:

ssh username@your-server-ip

Update your system:

sudo apt update && sudo apt upgrade -y

Install essential packages:

sudo apt install python3 python3-pip git ufw

Configure basic firewall:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8080/tcp  # For Web UI if not using reverse proxy
sudo ufw enable

If you're using a domain name:

# Install Nginx
sudo apt install nginx

# Install Certbot for SSL
sudo apt install certbot python3-certbot-nginx

# Configure SSL
sudo certbot --nginx -d yourdomain.com

Step 3: Install Ollama for DeepSeek

Install Ollama:

curl -fsSL https://ollama.com/install.sh | sh
ollama --version

Configure system service:

sudo systemctl start ollama
sudo systemctl enable ollama

Step 4: Set Up Version Control and Automated Deployment

1- Create a deployment user:

sudo adduser deploy
sudo usermod -aG sudo deploy

2- Configure SSH keys for DeployHQ:

# As deploy user
su - deploy
mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

3- Set up project structure:

mkdir -p /var/www/deepseek
chown deploy:deploy /var/www/deepseek

4- Initialise Git repository:

cd /var/www/deepseek
git init

5- Create deployment configuration:

deployment:
  environments:
    production:
      branch: main
      server: production-server
    # Only if we need a staging server, for example to test new models, etc
    staging:
      branch: staging
      server: staging-server

  commands:
    pre_deploy:
      - python3 -m venv venv
      - source venv/bin/activate
      - pip install -r requirements.txt

    post_deploy:
      - sudo systemctl restart ollama
      - sudo systemctl restart nginx

Step 5: Download and Configure DeepSeek Model

# Here you could download and configure other models as well such as: Mistral, Llama, etc
ollama run deepseek-r1:7b

Create model configuration:

# config/model_config.yml
model:
  name: deepseek-r1
  version: 7b
  parameters:
    temperature: 0.7
    max_tokens: 2048

Step 6: Set Up Web UI with Nginx Reverse Proxy

Install Web UI dependencies:

python3 -m venv venv
source venv/bin/activate
pip install open-webui

Configure Nginx reverse proxy:

# /etc/nginx/sites-available/deepseek
server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Enable the site:

sudo ln -s /etc/nginx/sites-available/deepseek /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Step 7: Continuous Deployment Workflow

1- In DeployHQ dashboard:

  • Create new project
  • Connect Git repository
  • Add server credentials
  • Configure deployment paths

2- Setup automatic deployments: It can be done directly on DeployHQ dashboard, in which a webhook to the repository needs to be installed.

Monitoring and Maintenance

1- Set up monitoring:

# Install monitoring tools
sudo apt install htop prometheus node-exporter

# Configure system monitoring
sudo systemctl enable prometheus node-exporter

2- Create backup script:

#!/bin/bash
# backup.sh
backup_dir="/backup/deepseek"
date=$(date +%Y%m%d)
tar -czf "$backup_dir/model_data_$date.tar.gz" /var/www/deepseek/data

Security Considerations

1- Configure rate limiting in Nginx:

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

2- Set up fail2ban:

sudo apt install fail2ban
sudo systemctl enable fail2ban

Conclusion

You now have a production-ready DeepSeek installation running on your cloud server with automated deployments through DeployHQ. The setup includes:

  • Secure access through SSL
  • Automated deployments
  • Monitoring and backup solutions
  • Rate limiting and security measures

Remember to regularly update your system and monitor resource usage, especially when running resource-intensive language models in a production environment.

Happy deploying!

A little bit about the author

Facundo is the CTO at DeployHQ. He oversees our software engineering team by day and, in his free time, enjoys hobbies such as cycling, spending time in nature, and the company of Bono 🐶

Tree

Proudly powered by Katapult. Running on 100% renewable energy.