Linux操作步骤

  1. mkdir my_wordpress
  2. cd my_wordpress
  3. # 创建docker-compose.yml可执行文件
  4. version: "3.9"
  5. services:
  6. db:
  7. image: mysql:5.7
  8. volumes:
  9. - db_data:/var/lib/mysql
  10. restart: always
  11. environment:
  12. MYSQL_ROOT_PASSWORD: somewordpress
  13. MYSQL_DATABASE: wordpress
  14. MYSQL_USER: wordpress
  15. MYSQL_PASSWORD: wordpress
  16. wordpress:
  17. depends_on:
  18. - db
  19. image: wordpress:latest
  20. volumes:
  21. - wordpress_data:/var/www/html
  22. ports:
  23. - "8000:80"
  24. restart: always
  25. environment:
  26. WORDPRESS_DB_HOST: db:3306
  27. WORDPRESS_DB_USER: wordpress
  28. WORDPRESS_DB_PASSWORD: wordpress
  29. WORDPRESS_DB_NAME: wordpress
  30. volumes:
  31. db_data: {}
  32. wordpress_data: {}
  33. # 后台启动
  34. docker-compose up -d

阿里云服务器,开放防火墙、配置安全组规则
浏览器访问 ip:8000
image.png
image.png