Dify 自行架設 - Claude 3.5 建議
By 蓉爸 RungBa
Created: 2025-01-26
Revised: 2025-01-26
繼使用 LXD/LXC 完成 n8n 的自架後,接下來就再來試試 Dify 的自架!
一樣,我不想用 Docker 方式來架設,但花了一些時間,Google 到的都是使用 Docker 的安裝方式,突然想到我該來問問 Claude 的,於是就有了下方的成果,待我試試 Claude 3.5 給的 installation guide …
不想用 Docker 方式架設的原因:
因 Docker 安裝後,整個 container image 會非常肥大,比一般不用Docker 方式建置的 image 大了 10 ~ 20 倍,而且也不利於備份,甚至發現備份時,無法成功匯出 container image,目前不確定是否是 LXD 系統本身還存在這個問題?!
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Dify Installation Guide for Ubuntu (Non-Docker)
Prerequisites
- Ubuntu 20.04 or newer
- Python 3.10 or newer
- Node.js 16+ and npm
- PostgreSQL 14+
- Redis
System Dependencies Installation
First, install required system packages:
PostgreSQL Setup
- Start PostgreSQL service:
- Create database and user:
Redis Setup
- Start Redis service:
Dify Installation
- Clone the repository:
- Set up Python virtual environment:
- Install backend dependencies:
- Configure environment variables:
Edit .env file with your database and Redis configurations:
- Install and build frontend:
Initialize Database
From the api directory:
Running the Application
- Start the backend server:
- Start the frontend development server:
Access the Application
Access the web interface at: http://localhost:3000
Common Issues and Troubleshooting
-
If you encounter PostgreSQL authentication issues:
- Check pg_hba.conf configuration
- Verify database user permissions
-
If Redis connection fails:
- Verify Redis is running:
sudo systemctl status redis-server
- Check Redis configuration in /etc/redis/redis.conf
-
Python package conflicts:
- Ensure you're using Python 3.10+
- Try recreating the virtual environment
-
Port conflicts:
- Check if ports 5001 and 3000 are available
- Use different ports by modifying the start commands
Security Considerations
- Change default passwords
- Configure proper firewall rules
- Set up SSL/TLS for production use
- Regularly update dependencies
Production Deployment
For production deployment, additional steps are recommended:
- Use a production-grade WSGI server (e.g., Gunicorn)
- Set up Nginx as a reverse proxy
- Configure proper security measures
- Set up SSL certificates
- Configure proper logging