docker安装wordpress
一、安装mariadb数据库
1、下载mariadb数据库镜像
root@docker:~l# docker pull mariadb Using default tag: latest latest: Pulling from library/mariadb 5b7339215d1d: Pull complete 14ca88e9f672: Pull complete a31c3b1caad4: Pull complete b054a26005b7: Pull complete 33ab3607a892: Pull complete 1b49a8418026: Pull complete a0a3f90ae566: Pull complete 8716c07293df: Pull complete 83f4f97abee6: Pull complete 7c35815f52bf: Pull complete 5231a02d319d: Pull complete cae978ab2e2e: Pull complete 3cbc0d35ef87: Pull complete a92cea29accf: Pull complete Digest: sha256:b1a66bc83c3fb2413ba850bfb55382a5dee0fb7716e1fba471f916b041cb6bbe Status: Downloaded newer image for mariadb:latest
查看下载的mariadb镜像 root@docker:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mariadb latest f55f3a2a2d81 6 days ago 354MB
2、创建外部存储数据库的文件目录
root@docker:~# mkdir /data/docker/mariadb -p
3、运行mariadb数据库,映射本地数据存储目录,映射本地和主机3306端口,创建mariadb数据库root密码
root@docker:~# docker run --name mariadb -e MYSQL_ROOT_PASSWORD=aa11223 -p 3306:3306 -v /data/docker/mariadb:/var/lib/mysql -d mariadb da98ec219d1eba2439221d6fd64b55169908e5afb96971c679159cb82bb6c87c
root@docker:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES da98ec219d1e mariadb "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 0.0.0.0:3306->3306/tcp mariadb
4、登陆mariadb容器环境
root@docker:~# docker exec -it mariadb bash root@da98ec219d1e:/# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.4.6-MariaDB-1:10.4.6+maria~bionic mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
5、创建数据库和用户
MariaDB [(none)]> create database wordpress character set utf8 collate utf8_general_ci; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> create user wordpress_user identified by 'Aa123456'; Query OK, 0 rows affected (0.002 sec) MariaDB [(none)]> grant all privileges on wordpress.* to wordpress_user; Query OK, 0 rows affected (0.002 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.001 sec)
二、安装wordpress
1、下载镜像
root@docker:~# docker pull wordpress Using default tag: latest latest: Pulling from library/wordpress f5d23c7fed46: Already exists 4f36b8588ea0: Already exists 6f4f95ddefa8: Already exists 187af28c9b1d: Already exists 3c4135e0a3e9: Already exists 764143bdfc93: Already exists 3a141d427998: Already exists 273ba44de0c6: Already exists a508367b4ba3: Already exists 0196a98ca6a5: Already exists 0accc27cff60: Already exists d9745b3647e0: Already exists f58c08d02c2b: Already exists a384fc11ca7c: Already exists 1f276e59f5e1: Already exists f797515c09c2: Already exists eb6cde1bd0a8: Already exists 8dae6df9c70a: Already exists 82dc50225733: Already exists Digest: sha256:bd7e91807fab130501cf026ad13e5c18745235ea1c89a5db36d9211ff384bb06 Status: Downloaded newer image for wordpress:latest root@docker:/data/docker# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mariadb latest f55f3a2a2d81 6 days ago 354MB wordpress latest 4ba1e63bd20c 9 days ago 501MB
2、运行wordpress容器环境,官方镜像是ubuntu+apache+mysql的,默认端口为80,映射本地端口为81,指定容器数据库,网站数据映射到本地
root@docker:/data/docker# docker run --name wordpress --link mariadb:mysql -p 81:80 -v /data/docker/web:/var/www/html -d wordpress f88431db84acc878516a5f2b7845522c3e9d62eec2cdb379502be98dfe6122ea
3、通过浏览器打开IP:81安装wordpress
安装完成后打开首页
至此,wordpress安装完成,大家有问题可以加QQ群进行交流。群号:955496382
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。