好物优选点击查看详情 京东购买

暂无内容

docker-compose安装wordpress

恢复原有wordpress推荐使用宝塔面板,本文介绍配置新的wordpress站点。

 yum update -y  yum install docker -y  yum list | grep docker  docker -v  vim /etc/docker/daemon.json { "registry-mirrors": ["https://hub-mirror.c.163.com","https://registry.aliyuncs.com","https://registry.docker-cn.com"]}  systemctl start docker.service  systemctl enable docker       

1.从github下载docker-compose二进制文件安装

 curl -L "https://github.com/docker/compose/releases/download/1.29.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose   chmod +x /usr/local/bin/docker-compose ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose docker-compose -v 

默认网络不支持指派固定IP,使用固定IP则需要自定义网络。

docker pull wordpress:latest docker pull mysql:5.7 docker run -d --privileged=true --name mysql_57 -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 33306:3306 mysql:5.7  docker run -d --name wp -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=123456 -e WORDPRESS_DB_NAME=wp -p 8000:80 --link mysql_57:mysql wordpress  firewall-cmd --zone=public --add-port=8000/tcp --permanentfirewall-cmd --reload  http://127.0.0.1:8000 

注意8888是宝塔面板的默认端口
mysql参考配置 : https://hub.docker.com/_/mysql

version: '3' networks: wp-net: services: mysql: image: "mysql:5.7" privileged: true container_name: "wp_mysql_5.7" restart: always networks: - wp-net ports: - "23306:3306" environment: MYSQL_ROOT_PASSWORD: "123456" MYSQL_DATABASE: "wordpress" MYSQL_USER: "wp_user" MYSQL_PASSWORD: "123456" TZ: Asia/Shanghai command: --wait_timeout=28800 --interactive_timeout=28800 --max_connections=1000 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M --sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO" volumes: - "./mysql-5.7/data:/var/lib/mysql" - "./mysql-5.7/config/my.cnf:/etc/mysql/my.cnf" wordpress: image: wordpress:latest container_name: wp depends_on: - mysql ports: - 8000:80 networks: - wp-net restart: always environment: WORDPRESS_DB_HOST: mysql WORDPRESS_DB_USER: wp_user WORDPRESS_DB_PASSWORD: 123456 volumes: - ./html:/var/www/html 

安装完毕之后,需要配置一下防火墙。

 firewall-cmd --zone=public --add-port=8000/tcp --permanent  firewall-cmd --reload 

在WordPress 根目录下的wp-config.php 文件大概79行下有下面一段代码:

define( 'WP_DEBUG', false ); 
 docker network prune 
docker logs 92143034fa98 

wordpress运行之后,一直提示:Error establishing a database connection

查看日志:docker logs wp_mysql

 define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'wp_user' ); /** MySQL database password */ define( 'DB_PASSWORD', '123456' ); /** MySQL hostname */ define( 'DB_HOST', '172.25.28.20' ); 
 docker-compose up -d  docker ps docker inspect 92143034fa98 
  mysql -h127.0.0.1 -uroot -P23306 -p mysql -h127.0.0.1 -uwp_user -P23306 -p > use mysql; > select Host,User from user; grant all on *.* to 'root'@'%' identified by '123456' with grant option; grant all on *.* to 'wp_user'@'%' identified by '123456' with grant option;   FLUSH PRIVILEGES; 

原文链接:https://blog.csdn.net/Duke147/article/details/127485088?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168623078216800225583599%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168623078216800225583599&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-3-127485088-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

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享