1.安装docker
#可运行docker版本19.03.01 #使用ranche脚本安装特定版本的docker https://releases.rancher.com/install-docker/19.01.sh #使用docker脚本安装最新版本的docker curl -sSL https://get.docker.com/ | sh #其他安装方式 https://docs.docker.com/install/linux/docker-ce/ubuntu/ #docker-release信息 https://github.com/docker/docker-ce/releases
2.安装docker-compose
#可运行docker-compose版本1.17.0 curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose #其他安装方式 https://github.com/docker/compose/releases #卸载方式直接删除可执行文件 sudo rm -rf /usr/local/bin/docker-compose
3.编辑docker-compose文件
version: '3.1' networks: wordpress: services: wordpress: image: wordpress:5.2.2-php7.3-apache restart: always ports: # - 8088:80 - 8443:443 environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: {{.db_user}} WORDPRESS_DB_PASSWORD: {{.db_password}} WORDPRESS_DB_NAME: {{.db_database}} HTTP_X_FORWARDED_PROTO: https volumes: #1,2,3均为了设置自动开启ssl - ./volumes/wordpress/sp-config/mods-enabled/ssl.load:/etc/apache2/mods-enabled/ssl.load - ./volumes/wordpress/sp-config/mods-enabled/ssl.conf:/etc/apache2/mods-enabled/ssl.conf - ./volumes/wordpress/sp-config/mods-enabled/socache_shmcb.load:/etc/apache2/mods-enabled/socache_shmcb.load #mount证书 - ./volumes/nginx/certs:/certs #mount443监听配置,配置证书 - ./volumes/wordpress/sp-config/sites-available/:/etc/apache2/sites-enabled/ #持久化网站信息,由于暂不清楚那些文件必须持久化,所以暂时全部mount - ./volumes/wordpress/mysite-html:/var/www/html/ networks: - wordpress depends_on: - db db: image: mysql:5.7 restart: always environment: MYSQL_DATABASE: {{.db_database}} MYSQL_USER: {{.db_user}} MYSQL_PASSWORD: {{.db_password}} MYSQL_RANDOM_ROOT_PASSWORD: '1' volumes: - ./volumes/mysql/mysql-storage:/var/lib/mysql ports: - 3306:3306 networks: - wordpress #由于多个服务在同一台机器的情况统一使用443端口,所以配置nginx(未使用443因为尚未备案) ng: image: nginx:1.9.5 restart: always volumes: - ./volumes/nginx/certs:/certs - ./volumes/nginx/nginx.conf:/etc/nginx/nginx.conf networks: - wordpress ports: - 8089:80 - 443:443 depends_on: - wordpress
4.启动
docker-compose up -d
5.解释
#以上配置为在wordpress容器中开启了apache tls,并且在nginx开启了tls #以上配置为最终版本,实际配置成功的流程为先不开启tls启动,install并生成数据库中数据后,再修改为tls,并修改数据库中数据 #首次安装路径http://ip:port/wp-admin/install.php #登录路径http://ip:port/wp-login.php #上传图片存储路径/var/www/html/wp-content/uploads(需持久化) #ubuntu16.04下apache配置存放路径:/etc/apache2/ #其中区分了xxx-available和xxx-enable # xxx-available为可用配置,开启的配置使用ln xxx xxx将available中文件软连接到enable中 # 上述配置直接将镜像available路径中相关文件拷贝、修改后mount到enable路径中 #出现报错'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?)是由于没有加载shmcb,mount相关文件即可 #wordpress中跟路径有home页面重定向,转发到数据库记录的home页面中 ##要注意开放端口或者修改配置,查看是否会造成重定向循环
原文链接:https://blog.csdn.net/rachel_92/article/details/98784333?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168994674616800227425886%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994674616800227425886&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-26-98784333-null-null.268%5Ev1%5Ekoosearch&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END