⚡ Setup Dify — LLM Application Platform
Deploy Dify on Ubuntu with Docker — an open-source LLM application development platform with visual workflow builder, RAG knowledge bases, agent orchestration, and one-click API publishing. Build AI-powered apps without writing backend code.
📦 Resources & Setup Scripts
Grab the automated bash script from GitHub to follow along with the video.
Quick Install:
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/ai/dify/dify-ubuntu.sh
chmod +x dify-ubuntu.sh
sudo bash dify-ubuntu.sh
Tutorial Steps
1 Download & Run the Script
The script installs Docker and deploys the full Dify stack — API server, worker, web frontend, PostgreSQL, Redis, and Weaviate vector database.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/ai/dify/dify-ubuntu.sh
chmod +x dify-ubuntu.sh
sudo bash dify-ubuntu.sh
2 Create Your Admin Account
Open your browser and navigate to Dify. Complete the initial setup to create your admin account and your first workspace:
http://<your-server-ip>
3 Add Your LLM Provider
Go to Settings → Model Provider. Add Ollama (local) by entering your Ollama API base URL, or add an OpenAI/Anthropic API key for cloud models.
4 Build Your First App
Click "Create App" and choose from Chatbot, Text Generator, Agent, or Workflow. Use the visual builder to design prompts, add knowledge bases, and publish a ready-to-use API or embedded chat widget.
Ports Used
| Port | Purpose |
|---|---|
| 80 | Dify Web UI |
| 5001 | Dify API Server |
Overview
Dify is an open-source LLM application development platform that lets you build, test, and deploy AI-powered applications through a visual interface. It supports chatbots, text generators, autonomous agents, and complex multi-step workflows — all without writing backend server code. Dify connects to dozens of LLM providers (Ollama, OpenAI, Anthropic, Google, Azure) and has a built-in knowledge base system for RAG. Each app you build can be published as a web UI, embedded widget, or REST API in a few clicks.
Why Use It
Dify collapses the stack required to build a production LLM application. What normally requires a backend server, LLM SDK integration, vector database setup, embedding pipeline, and a frontend takes hours to weeks of engineering work. With Dify, the same result is achievable through a visual workflow builder in under an hour. Its strength over AnythingLLM is the ability to build multi-step agents and publish them as APIs — making it the right choice when you want to integrate AI capabilities into existing products or automate complex reasoning tasks.
When You Need It
Who Should Use It
Real Use Cases
Main Features
How to Use After Installation
Security Best Practices
Ports and Firewall Notes
Dify's web frontend runs on port 80 and the API server on port 5001. Block port 5001 from public access — it is an internal service port. Expose only port 80 through a reverse proxy with HTTPS termination. If Ollama runs on the same server, use http://host.docker.internal:11434 as the Ollama base URL inside Dify's container network. PostgreSQL (5432), Redis (6379), and Weaviate (8080) are internal services — keep them bound to the Docker network only.
Backup and Maintenance
Common Mistakes
Troubleshooting
Alternatives
AnythingLLM is simpler and better for document Q&A use cases with less focus on building publishable apps. Flowise offers a no-code LangChain pipeline builder that is easier to start with but less powerful for complex workflows. n8n with AI nodes is better if you need AI as one part of a broader automation pipeline connecting many external services. LangChain and LlamaIndex are code-only alternatives that give maximum flexibility at the cost of significant engineering effort. For enterprise-grade MLOps with model serving, monitoring, and governance, platforms like MLflow or BentoML are more appropriate. Dify's sweet spot is teams that want to move fast from AI idea to deployed product.
When Not to Use It
Dify is not the right tool if you need high-throughput batch processing of millions of documents — it is optimized for interactive apps and moderate-scale pipelines. If your team is building a pure data pipeline (not user-facing), Apache Airflow or Prefect with Python LLM libraries give more control. If you only need document Q&A without custom workflows, AnythingLLM is simpler to set up and maintain. Dify also requires significant server resources — the full stack (API, worker, PostgreSQL, Redis, Weaviate) needs at least 4 GB RAM and 20 GB disk to run comfortably.
Need Help Setting Up Dify?
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
Frequently Asked Questions
What is the difference between Dify and AnythingLLM?
AnythingLLM is focused on document Q&A — upload files to a workspace and chat with them. Dify is an application development platform focused on building and publishing AI-powered apps with visual workflows, agent tools, and REST APIs. AnythingLLM is better for internal knowledge bases. Dify is better when you want to build AI features for products, create multi-step agents, or publish AI capabilities as APIs for other systems to consume.
Can I use Dify with a local Ollama model?
Yes. In Dify's Settings → Model Provider, add Ollama and set the base URL to http://your-server-ip:11434 (or http://host.docker.internal:11434 if Ollama runs on the same Docker host). All models you have pulled in Ollama will appear in Dify's model selector. You can mix local Ollama models for some apps and cloud models (OpenAI, Anthropic) for others in the same Dify instance.
What is a Dify workflow and how is it different from a chatbot?
A chatbot in Dify is a single-turn or multi-turn conversation app backed by an LLM. A workflow is a visual graph of connected nodes — each node can be an LLM call, a code block, an HTTP request, a knowledge retrieval step, or a conditional branch. Workflows are best for automation tasks that require multiple steps, branching logic, or integration with external APIs, while chatbots are better for open-ended conversational interfaces.
How do I publish a Dify app as an API?
Open your app, go to the API Reference tab, and click 'Generate API Key'. You get a REST endpoint and an API key. Send POST requests with the user's message in the request body. The API returns the LLM response in streaming or blocking mode. This lets you embed Dify's AI logic into your existing application backend, mobile app, or automation tool without any additional server code.
Does Dify support agent tools like web search?
Yes. Dify supports tool-calling agents. Built-in tools include web search (via Bing, Google, or SerpAPI), a Python code interpreter, Wikipedia, Wolfram Alpha, and more. You can also add custom tools by defining them as OpenAPI spec JSON. In a workflow app, you can add a tool node to any step in the graph. The agent will automatically call the tool when it determines it needs external information.
Can multiple team members collaborate on building apps in Dify?
Yes. Dify supports team workspaces with member roles: Owner, Admin, Editor, and Member. Editors can create and modify apps but cannot change workspace settings. Multiple people can work on different apps simultaneously. App configurations are stored in the PostgreSQL database, so all changes are persisted centrally. There is no real-time co-editing of the same app, but team members can sequentially edit shared apps.
What vector database does Dify use?
By default, Dify uses Weaviate as the vector store for knowledge base embeddings. You can configure it to use alternative vector databases — Qdrant, Milvus, OpenSearch, or PGVector (PostgreSQL extension) — by setting environment variables in the Docker Compose file. Weaviate is a good default for most self-hosted deployments. For very large knowledge bases (millions of documents), Milvus or Qdrant may offer better performance.
How resource-intensive is Dify compared to simpler tools?
Dify is one of the heavier self-hosted AI platforms. The full stack requires at minimum 4 GB RAM (8 GB recommended), 4 CPU cores, and 20+ GB disk. It runs six or more Docker containers simultaneously (API, worker, web, nginx, PostgreSQL, Redis, Weaviate). Simpler tools like AnythingLLM run in a single container with 1–2 GB RAM. If resources are constrained, consider AnythingLLM or Flowise instead. If you have the resources, Dify's capabilities justify the overhead.
