wordpress服务器镜像化改造

firstly:backup:

mysqlbackup:整库备份,我用的是Navicat把数据导出来;
WordPressbackup:wordpress图片和主题都在wp-content这个目录下,我们只需要备份这个目录即可。

1.安装最新版的docker:

--卸载旧版本: yum remove docker                   docker-common                   docker-selinux                   docker-engine
--安装依赖:yum install -y yum-utils device-mapper-persistent-data lvm2
--更新yum文件:yum-config-manager      --add-repo      https://download.docker.com/linux/centos/docker-ce.repo
--yum makecache fast
--安装:yum install docker-ce

2.因为wordpress需要使用多个docker镜像,所以在此我们使用docker-compose编排工具,进行管理。

安装docker-compose,使用如下命令:

curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose –version

3.拉取两个镜像:

docker pull mysql
docker pull wordpress

#########日常维护#################

#############报错汇总##########################

(1)docker-compose:

–version使用单引号时报错,使用双引号问题解决,查看具体版本使用docker-compose version

ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

–格式问题报错:有时候直接从网上拷贝的话,某些特殊符号比如-等就会出现是中文字符;而且报错挺明显的,这些地方都有这个符号;

[root@VM_0_11_centos docker_compose]# docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.mysqldb.volumes contains an invalid type, it should be an array
services.wordpress.volumes contains an invalid type, it should be an array
services.mysqldb.ports contains an invalid type, it should be an array
services.wordpress.ports contains an invalid type, it should be an array
services.wordpress.depends_on contains an invalid type, it should be an array

–不同的服务不能包含:看清报错描述;    

ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.mysqldb: 'wordpress'

(2)mysql报错:关联数据目录重新建镜像的时候记得删除;

[ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800!

—最大文件大小:修改配置文件max_allowed_packet=400M

[ERR] 1153 - Got a packet bigger than 'max_allowed_packet' bytes
[ERR]

(3)迁移的时候,图片是保存在wp-comment路径下的,记得备份;

(4)mysql执行报错,去排查原因,看日志,再一次犯了之前盲目的错,怀疑是数据库版本问题,白白浪费时间;不要主观臆断,如果怀疑,请找到数据,否则,不要逼逼!

–报错1,插入时间格式问题报错:参考网上修改之后还有问题,直接修改数据文件,保存后导入;

Incorrect datetime value: '0000-00-00 00:00:00' for column

—网上修改方案:https://www.cnblogs.com/huanhang/p/7050757.html

show variables like ‘%sql_mode%’;
set global sql_mode=’STRICT_TRANS_TABLES,STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER’;

(5)界面英文无法修改或者下载插件时提示ftp:“To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host”解决方法:修改/var/www/html文件夹的权限;

chown -R www-data:www-data /var/www/html

(6)图片超过大小限制:

新建一个php.ini文件,在你的主机空间的根目录新建一个php.ini文件,里面使用如下代码。
复制代码
代码如下:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

(7)docker和主机之间文件的传输:https://blog.csdn.net/leafage_m/article/details/72082011

docker cp 本地文件路径 ID全称:容器路径
docker cp baidu_verify_5n6o8JrbR2.html 7c86cef8780c752c1813b4fc67f7a29426afd61a295e9dc12c15a9df92229d6c:/var/www/html/baidu_verify_5n6o8JrbR2.html

--获得全称使用:docker inspect -f '{{.Id}}' roarlion_wordpress
从容器拷贝到主机上,则相反:
--docker cp ID全称:容器文件路径 本地路径

(8)Apache启动报错:Invalid command '*module', perhaps misspelled or defined by a module not inclu ded in t,经过排查,发现模块被删掉了;

#############引用和参考##################################

迁移:https://www.ilanni.com/?p=12889

keepalived日志修改路径:https://blog.csdn.net/liyuling52011/article/details/80033229

lamp:https://blog.51cto.com/andyxu/2177116

#############

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据