Skip to main content

Prerequisites

Setup Docker and Docker Compose

Before installing Dify, make sure your machine meets the following minimum system requirements:
  • CPU >= 2 Core
  • RAM >= 4 GiB
If you need to use OpenAI TTS, FFmpeg must be installed on the system for it to function properly. For more details, refer to: Link.

Clone Dify Repository

Run the git command to clone the Dify repository.

Start Middlewares with Docker Compose

A series of middlewares for storage (e.g. PostgreSQL / Redis / Weaviate (if not locally available)) and extended capabilities (e.g. Dify’s sandbox and plugin-daemon services) are required by Dify backend services. Start the middlewares with Docker Compose by running these commands:

Setup Backend Services

The backend services include
  1. API Service: serving API requests for Frontend service and API accessing
  2. Worker Service: serving the aync tasks for datasets processing, workspaces, cleaning-ups etc.

Start API Service

  1. Navigate to the api directory:
  2. Prepare the environment variable config file:
    When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site’s top-level domain (e.g., example.com) in the .env file.The frontend and backend must be under the same top-level domain to share authentication cookies.
  3. Generate a random secret key and replace the value of SECRET_KEY in the .env file:
  4. Install dependencies: uv is used to manage dependencies. Install the required dependencies with uv by running:
    For macOS: install libmagic with brew install libmagic.
  5. Perform the database migration: Perform database migrations to the latest version:
  6. Start the API service:
    Expected output:

Start the Worker Service

To consume asynchronous tasks from the queue, such as dataset file import and dataset document updates, follow these steps to start the Worker service
  • for macOS or Linux
    If you are using a Windows system to start the Worker service, please use the following command instead:
  • for Windows
    Expected output:

Start the Beat Service

Additionally, if you want to debug the celery scheduled tasks or run the Schedule Trigger node, you can run the following command in another terminal to start the beat service:

Setup Web Service

Start the web service is built for frontend pages .

Environment Preparation

To start the web frontend service, Node.js v22 (LTS) and PNPM v10 are required.
  • Install NodeJS Please visit https://nodejs.org/en/download and choose the installation package for your respective operating system that is v18.x or higher. LTS version is recommanded for common usages.
  • Install PNPM Follow the the installation guidance to install PNPM. Or just run this command to install pnpm with npm.

Start Web Service

  1. Enter the web directory:
  2. Install dependencies:
  3. Prepare the environment variable configuration file
    Create a file named .env.local in the current directory and copy the contents from .env.example. Modify the values of these environment variables according to your requirements:
  4. Build the web service:
  5. Start the web service:
    Expected output:

Access Dify

Access http://localhost:3000 via browsers to enjoy all the exciting features of Dify. Cheers ! 🍻
Last modified on June 10, 2026