泰州网站制作企业,建设网站的费用吗,新网域名搭建网站,小公司根本办不了icp许可证目录
方式一docker安装#xff1a;
方式二源码安装#xff1a; Dify本地安装可以用docker方式#xff0c;和源码编译方式。
先到云厂商平台申请一台Centos系统云主机#xff0c;网络选择海外#xff0c;需要公网IP#xff0c;再按一下流程操作#xff1a;
方式一doc…目录
方式一docker安装
方式二源码安装 Dify本地安装可以用docker方式和源码编译方式。
先到云厂商平台申请一台Centos系统云主机网络选择海外需要公网IP再按一下流程操作
方式一docker安装
安装docker composehttps://blog.csdn.net/weixin_56781779/article/details/132258636
安装dify并启动
git clone https://github.com/langgenius/dify.gitcd dify/dockerexport EXPOSE_NGINX_PORT8080docker compose up -d启动后docker ps 可以看到以下容器 netstat -natp可以看到docker监听的端口是8080设置安全组开发8080端口 访问 http://虚拟机ip:8080 根据情况输邮箱用户名密码 完成本地注册可以开始使用 方式二源码安装
源码安装主要可以参考文档
https://docs.dify.ai/zh-hans/getting-started/install-self-hosted/local-source-code
文档里有一些要调整的地方
安装数据库
sudo apt-get update#安装pg redis
sudo apt install redis-server wget postgresql postgresql-client -ysudo apt install nginx nodejs npm -ysudo wget https://github.com/weaviate/weaviate/releases/download/v1.27.12/weaviate-v1.27.12-linux-amd64.tar.gzsudo tar -zxf weaviate-v1.27.12-linux-amd64.tar.gz#安装向量数据库
sudo chmod x weaviatesudo mv weaviate /opt 设置数据库密码
修改/etc/redis/redis.conf添加requirepass difyai123456
启动redis
service redis-server start
启动pg
service postgresql start
修改pg密码
su - postgrespsqlCREATE DATABASE dify;ALTER USER postgres WITH PASSWORD difyai123456;quit;
启动weaviate
export PERSISTENCE_DATA_PATH/var/lib/weaviate
export QUERY_DEFAULTS_LIMIT25
export AUTHENTICATION_ANONYMOUS_ACCESS_ENABLEDfalse
export DEFAULT_VECTORIZER_MODULEnone
export CLUSTER_HOSTNAMEnode1
export AUTHENTICATION_APIKEY_ENABLEDtrue
export AUTHENTICATION_APIKEY_ALLOWED_KEYSWVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
export AUTHENTICATION_APIKEY_USERShellodify.ai
export AUTHORIZATION_ADMINLIST_ENABLEDtrue
export AUTHORIZATION_ADMINLIST_USERShellodify.aicd /opt
nohup ./weaviate --host 0.0.0.0 --port 8080 --scheme http |tee ./weaviate.log 21 再按照文档进行源码安装文档中
如果执行poetry shell失败的话以下命令要带上poetry run否则会报错
poetry run flask db upgrade启动前端后端和worker
#启动前端
export NEXT_PUBLIC_DEPLOY_ENVDEVELOPMENT
export NEXT_PUBLIC_EDITIONSELF_HOSTED
export NEXT_PUBLIC_API_PREFIX/console/api #不设置默认访问http://localhost/console/api
export NEXT_PUBLIC_PUBLIC_API_PREFIX/api #不设置默认访问http://localhost/api
export NEXT_PUBLIC_SENTRY_DSN
export NEXT_TELEMETRY_DISABLED1
export NEXT_PUBLIC_UPLOAD_IMAGE_AS_ICONfalse
export NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS60000
export NEXT_PUBLIC_CSP_WHITELIST
export NEXT_PUBLIC_TOP_K_MAX_VALUE10
export NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH4000
nohup npm run start #启动worker
#start backend
export CONSOLE_API_URL
export APP_API_URL
export WEB_SENTRY_DSN
export NEXT_TELEMETRY_DISABLED0
export TEXT_GENERATION_TIMEOUT_MS60000
export CSP_WHITELIST
export TOP_K_MAX_VALUE10
export INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH4000
cd /app/dify/api
nohup poetry run celery -A app.celery worker -P gevent -c 1 -Q dataset,generation,mail,ops_trace --loglevel INFO ./celery.log 21 nohup poetry run flask run --host 0.0.0.0 --port5001 --debug |tee ./backend.log 21
这样跑起来只适合本机访问如果要从公网访问还要假一层nginx我们在前面已安装nginx这里我们就配置nginx让其可以代理访问dify
修改/etc/nginx/nginx.conf如下
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;events {worker_connections 768;# multi_accept on;
}http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main $remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for;access_log /var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65;#gzip on;client_max_body_size 15M;include /etc/nginx/conf.d/*.conf;
}修改文件 /etc/nginx/conf.d/default.conf
server {listen 8080;server_name _;location /console/api {proxy_pass http://127.0.0.1:5001;}location /api {proxy_pass http://127.0.0.1:5001;}location /v1 {proxy_pass http://127.0.0.1:5001;}location /files {proxy_pass http://127.0.0.1:5001;}location / {proxy_pass http://127.0.0.1:3000;}}重启nginxsystemctl restart nginx
通过命令netstat -natp 确认nginx确实监听8080端口
访问 http://虚拟机ip:8080 后续页面访问同方式一