1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DifyをRHEL9にインストールしてみた

Last updated at Posted at 2025-09-02

1. はじめに

Difyは、オープンソースのAIアプリケーション開発プラットフォーム です。ChatGPTのような大規模言語モデル(LLM)を利用したアプリやエージェントを、コーディングなしでも作成・運用できる「AIアプリ構築基盤」です。Githubに書かれていたことの受け売りですが、以下の特徴があります。

  • ワークフロー
    視覚的なキャンバス上で、AIのワークフローを組み立てたりテストしたりできます。ドラッグ&ドロップ感覚で直感的に扱え、さまざまな機能を組み合わせて柔軟に設計できます。
  • 幅広いモデル対応
    GPTやMistral、Llama3などをはじめ、OpenAI API互換モデルや数多くのオープンソース/商用LLMをそのまま利用できます。外部の推論サービスやセルフホスト型の環境ともスムーズに連携可能です。
  • プロンプトIDE
    プロンプトを作ったり、モデルごとの応答を比較したりできる専用の画面があります。さらに、チャットアプリに音声合成(Text-to-Speech)などの機能を簡単に追加できます。
  • RAGパイプライン
    文書を取り込んで検索に活用できる仕組みが標準で備わっています。PDFやPPTなど一般的なファイルからテキストを抜き出して、そのまま質問応答に活かせます。
  • エージェント機能
    LLMの「関数呼び出し」や「ReAct」に基づいてエージェントを作成できます。Google検索やDALL-E、Stable Diffusion、WolframAlphaなど、50種類以上の便利なツールが最初から組み込まれており、自作ツールの追加も可能です。
  • LLMOps(運用管理)
    アプリのログや動作状況を確認しながら、継続的にプロンプトやデータ、モデルを改善できます。本番環境の利用データをそのまま改善サイクルに活かせるのが強みです。
  • Backend-as-a-Service
    Difyの機能はすべてAPIとしても提供されているので、自社システムやアプリケーションにシームレスに組み込めます。

Difyにはクラウド版もあるのですが、ローカル環境にインストールすることができるCommunity Editionも存在し、なんと「CPU >= 2 Core, RAM >= 4 GiB」という小規模なリソースでも稼働させることができます。

本稿ではDifyをIBM Cloud(VSI for VPC)上のRHEL9にインストールしてみます。

2. Dockerのインストール

モジュールの最新化
[root@syasuda-ollama ~]# dnf -y update
[root@syasuda-ollama ~]# reboot
環境確認
[root@syasuda-ollama ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.6 (Plow)

[root@syasuda-ollama ~]# uname -a
Linux syasuda-ollama 5.14.0-570.37.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Aug 16 01:10:00 EDT 2025 x86_64 x86_64 x86_64 GNU/Linux

[root@syasuda-ollama ~]# hostnamectl
 Static hostname: syasuda-ollama
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: 09f2d8a3f371b99ff6e334c58749ec98
         Boot ID: 3d05a7dac11d4b588a2d78a211f0ac47
  Virtualization: kvm
Operating System: Red Hat Enterprise Linux 9.6 (Plow)
     CPE OS Name: cpe:/o:redhat:enterprise_linux:9::baseos
          Kernel: Linux 5.14.0-570.37.1.el9_6.x86_64
    Architecture: x86-64
 Hardware Vendor: QEMU
  Hardware Model: Standard PC _i440FX + PIIX, 1996_
Firmware Version: 1.15.0-1
Dockerのインストールとサービスの自動起動時の有効化およびサービスの起動
[root@syasuda-ollama ~]# dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
[root@syasuda-ollama ~]# dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
[root@syasuda-ollama ~]# systemctl enable --now docker

3. Difyのインストール

gitのインストール
[root@syasuda-ollama ~]# dnf install -y git
Difyのダウンロード
[root@syasuda-ollama ~]# git clone https://github.com/langgenius/dify.git
環境ファイルを作成(とは言っても、既存のサンプルをそのままコピーするだけだが)
[root@syasuda-ollama ~]# cd dify/
[root@syasuda-ollama dify]# cd docker/
[root@syasuda-ollama docker]# cp -p .env.example .env

docker-compose.yamlをチェックすると、たくさんのサービスが稼働し、尚且つ./volumes配下に永続化されていることが分かる。領域不足を避けるため、/workという大容量の領域を作成し、そこに./volumesを移動しシンボリックリンクを張る。

./volumes領域の退避
[root@syasuda-ollama docker]# mkdir -p /work/dify
[root@syasuda-ollama docker]# mv volumes /work/dify/.
[root@syasuda-ollama docker]# ln -s /work/dify/volumes volumes
[root@syasuda-ollama docker]# ls -l volumes
lrwxrwxrwx. 1 root root 18 Sep  2 00:06 volumes -> /work/dify/volumes
Difyの起動
[root@syasuda-ollama docker]# docker compose up -d
Difyの起動確認
[root@syasuda-ollama docker]# docker compose ls
NAME                STATUS              CONFIG FILES
docker              running(11)         /root/dify/docker/docker-compose.yaml

[root@syasuda-ollama docker]# docker compose ps
NAME                     IMAGE                                       COMMAND                  SERVICE         CREATED         STATUS                   PORTS
docker-api-1             langgenius/dify-api:1.8.0                   "/bin/bash /entrypoi…"   api             5 minutes ago   Up 5 minutes             5001/tcp
docker-db-1              postgres:15-alpine                          "docker-entrypoint.s…"   db              6 minutes ago   Up 5 minutes (healthy)   5432/tcp
docker-nginx-1           nginx:latest                                "sh -c 'cp /docker-e…"   nginx           5 minutes ago   Up 4 minutes             0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp
docker-plugin_daemon-1   langgenius/dify-plugin-daemon:0.2.0-local   "/bin/bash -c /app/e…"   plugin_daemon   5 minutes ago   Up 5 minutes             0.0.0.0:5003->5003/tcp, [::]:5003->5003/tcp
docker-redis-1           redis:6-alpine                              "docker-entrypoint.s…"   redis           6 minutes ago   Up 5 minutes (healthy)   6379/tcp
docker-sandbox-1         langgenius/dify-sandbox:0.2.12              "/main"                  sandbox         6 minutes ago   Up 5 minutes (healthy)
docker-ssrf_proxy-1      ubuntu/squid:latest                         "sh -c 'cp /docker-e…"   ssrf_proxy      6 minutes ago   Up 5 minutes             3128/tcp
docker-weaviate-1        semitechnologies/weaviate:1.19.0            "/bin/weaviate --hos…"   weaviate        6 minutes ago   Up 5 minutes
docker-web-1             langgenius/dify-web:1.8.0                   "/bin/sh ./entrypoin…"   web             6 minutes ago   Up 5 minutes             3000/tcp
docker-worker-1          langgenius/dify-api:1.8.0                   "/bin/bash /entrypoi…"   worker          5 minutes ago   Up 5 minutes             5001/tcp
docker-worker_beat-1     langgenius/dify-api:1.8.0                   "/bin/bash /entrypoi…"   worker_beat     5 minutes ago   Up 5 minutes             5001/tcp

[root@syasuda-ollama docker]# docker compose images
CONTAINER                REPOSITORY                      TAG                 PLATFORM            IMAGE ID            SIZE                CREATED
docker-api-1             langgenius/dify-api             1.8.0               linux/amd64         4c23edde3f79        2.25GB              292 years ago
docker-db-1              postgres                        15-alpine           linux/amd64         06686173a6eb        274MB               292 years ago
docker-nginx-1           nginx                           latest              linux/amd64         ad5708199ec7        192MB               292 years ago
docker-plugin_daemon-1   langgenius/dify-plugin-daemon   0.2.0-local         linux/amd64         09f2d92bce00        1.37GB              292 years ago
docker-redis-1           redis                           6-alpine            linux/amd64         b7f611844a19        30.2MB              292 years ago
docker-sandbox-1         langgenius/dify-sandbox         0.2.12              linux/amd64         ba1b250b9505        578MB               292 years ago
docker-ssrf_proxy-1      ubuntu/squid                    latest              linux/amd64         feec1ad0ab0a        213MB               292 years ago
docker-weaviate-1        semitechnologies/weaviate       1.19.0              linux/amd64         8ec9f084ab23        52.5MB              292 years ago
docker-web-1             langgenius/dify-web             1.8.0               linux/amd64         f8ddef2232b5        537MB               292 years ago
docker-worker-1          langgenius/dify-api             1.8.0               linux/amd64         4c23edde3f79        2.25GB              292 years ago
docker-worker_beat-1     langgenius/dify-api             1.8.0               linux/amd64         4c23edde3f79        2.25GB              292 years ago

4. Difyにブラウザアクセスする。

  • http://<VSI for VPCのIPアドレス>にアクセス。メールアドレス, ユーザー名、パスワードを設定。image.png
  • ログインできた。image.png
  • たくさんの事前準備されたアプリやツールがある。image.pngimage.png
1
0
2

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?