1. # 1.获取FastDFS镜像
    2. docker load -i fastdfs_docker.tar
    3. # 2.安装tracker 将运行目录映射到宿主机的/var/fdfs/tracker
    4. docker run -dti --network=host --name tracker -v /var/fdfs/tracker:/var/fdfs delron/fastdfs tracker
    5. # 3.安装storage容器->Tracker的ip地址不要使用127.0.0.1,使用虚拟机IP
    6. docker run -dti --network=host --name storage -e TRACKER_SERVER=82.156.189.83:22122 -v /var/fdfs/storage:/var/fdfs delron/fastdfs storage
    7. # 4.查看目录
    8. cd /var/fdfs
    9. # 5.安装FastDFS客户端扩展
    10. pip install fdfs_client-py-master.zip
    11. pip install mutagen==1.44.0 #注意,当前最新版本 有些东西变了,不指定,运行会报错
    12. pip install requests
    13. # 6.在utils中导入fastdfs
    14. # 7.配置Settings
    15. CORS_ORIGIN_WHITELIST = [
    16. 'http://IP',
    17. 'http://IP:80',
    18. 'http://IP:8080',
    19. 'http://IP:8888',
    20. ]
    21. FDFS_URL = 'http://IP:8888/'
    22. FDFS_CLIENT_CONF = os.path.join(BASE_DIR, 'shop/utils/fastdfs/client.conf')
    23. DEFAULT_FILE_STORAGE = 'shop.utils.fastdfs.fastdfs_storage.FastDFSStorage'
    24. # 8.Linux进入项目目录下启动shell
    25. python manage.py shell
    26. # 9.shell中输入
    27. from fdfs_client.client import Fdfs_client
    28. FDFS_Client = Fdfs_client('shop/utils/fastdfs/client.conf')
    29. ret = FDFS_Client.upload_by_filename('../shop/static/frontend/images/adv01.jpg')
    30. # 10.进入storage文件夹下,删除原有的Data,导入data.tar.gz文件
    31. sudo cp ~/data.tar.gz data.tar.gz
    32. sudo tar -zxvf data.tar.gz
    33. # 11.修改index.html的地址
    34. IP:8888