1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuでDify環境構築

Last updated at Posted at 2025-03-08

はじめに

Ubuntuを搭載したVPSサーバーでDifyの環境を構築します

環境

・サーバー: Ubuntu 24.04 LTS

手順

サーバーにDockerとDockerComposeをインストール

  1. Dockerの公式GPGキーを追加
    sudo apt-get update
    sudo apt-get install ca-certificates curl
    sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc
    

  2. Aptソースにリポジトリを追加
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get update
    

  3. Docker関連のパッケージをインストール
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    

  4. Hello Worldコンテナを実行してDockerが正しく動作していることを確認
    sudo docker run hello-world
    

Difyの設定と起動

  1. Difyのリポジトリをクローン
    git clone https://github.com/langgenius/dify.git
    

  2. 環境変数の設定
    cd dify/docker
    cp .env.example .env
    

  3. Docker ComposeでDifyの起動
    docker compose up -d
    

  4. ブラウザから初期設定アクセス
    http://<サーバーのIPアドレス>/install
    

  5. アクセスできました
    スクリーンショット 2025-03-08 115819.png

追記

コードブロックが「Loading...」となり、コードが記述できない状態であったため、以下を追加で実施

# ディレクトリ移動
cd dify/docker

# コンテナ停止
docker compose down

# 最新コードを取得
git pull origin main

# 最新のDockerイメージを取得
docker compose pull

# .envを最新に
cp .env.example .env

# コンテナ起動
docker compose up -d
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?