wordpress:6.3的docker部署
一.docker部署mysql5.7数据库
docker pull mysql:5.7
mkdir -p /data/mysql/data /data/mysql/logs /data/mysql/conf
touch /data/mysql/conf/my.cnf
docker run --restart=always -p 13306:3306 --name mysql -v /data/mysql/conf:/etc/mysql/conf.d -v /data/mysql/logs:/logs -v /data/mysql/data:/var/lib/mysql -v /etc/localtime:/etc/localtime:ro -e MYSQL_ROOT_PASSWORD=111111 -d mysql:5.7
docker exec -it mysql bash
二.创建wordpress用户
1、root登录服务器 进入数据库 mysql -u root -p111111
2、创建数据库 create database wordpress; shop 为数据库名称
3、查看创建数据库 show databases; (小命令 use shop; 进入数据库 show table;)
4、创建数据库的用户
create user 'wordpress'@'%' identified by '111111';
'wordpress' 用户名称
'111111' 用户密码
@后的命令解释
'%' - 所有情况都能访问
'localhost' - 本机才能访问
'111.222.33.44' - 指定 ip 才能访问
5、给予新用户的授予权限
grant all on wordpress.* to wordpress@'%' identified by "111111";
all 可以替换为 select,delete,update,create,drop
数据库名 所有的 用*
数据库表 所有的 用*
6、查看权限
show grants for 'wordpress'@'%' (如果定义了指定ip 访问 就需要更改为ip地址)
7、删除用户
drop user 用户名称
8、修改用户
rename user '用户名称'@'ip地址/%' to '新用户'@'ip地址/%';
9、修改密码set password for '用户名'@'IP地址' = Password('新密码');
三.docker部署wordpress服务
docker run -itd --name=wordpress --restart=always -v /data/wordpress/html:/var/www/html --link mysql:mysql -p 8888:80 -d wordpress:6.3
http://192.168.1.1:8888/
http://192.168.1.1:8888/wp-login.php #登录wordpress
wordpress:6.3k8s部署方式
重点就是将数据库连接配置设置好就行,没啥技术难点
---
apiVersion: apps/v1
kind: Deployment
metadata:name: test-wordpresslabels:app: wordpressenv: testteam: scorpiorole: service
spec:selector:matchLabels:app: wordpressenv: testteam: scorpiorole: servicereplicas: 1strategy:rollingUpdate:maxSurge: 20%maxUnavailable: 5%type: RollingUpdatetemplate:metadata:name: wordpressannotations:proxy.istio.io/config: |terminationDrainDuration: "35s"labels:app: wordpressenv: testteam: scorpiorole: servicespec:terminationGracePeriodSeconds: 65containers:- name: wordpressimage: wordpress:6.3imagePullPolicy: IfNotPresentenv:- name: WORDPRESS_DB_HOSTvalue: '192.168.1.1:13306'- name: WORDPRESS_DB_USERvalue: 'root'- name: WORDPRESS_DB_PASSWORDvalue: 'wordpress'- name: WORDPRESS_DB_NAMEvalue: 'wordpress'- name: TZvalue: Asia/Shanghaiports:- containerPort: 80name: http-port
# livenessProbe:
# httpGet:
# path: /actuator/health
# port: http-port
# initialDelaySeconds: 10
# timeoutSeconds: 30
# periodSeconds: 30
# failureThreshold: 3
# readinessProbe:
# httpGet:
# path: /actuator/health
# port: http-port
# initialDelaySeconds: 10
# timeoutSeconds: 30
# failureThreshold: 3volumeMounts:- name: var-www-htmlmountPath: /var/www/htmlvolumes:- name: var-www-htmlhostPath:path: /data/var/www/htmltype: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:name: test-wordpresslabels:app: wordpressenv: testteam: scorpiorole: service
spec:type: ClusterIPports:- port: 80targetPort: 80protocol: TCPselector:app: wordpressenv: testteam: scorpiorole: service
registry.cn-shenzhen.aliyuncs.com/gemdale/wordpress:6.3.0-php8.2-apache #这个镜像是wordpress6.3推入本地镜像仓库的镜像