如何在centos7中使用docker建立wordpress博客以及踩坑记录
这期内容当中小编将会给大家带来有关如何在centos7中使用docker建立wordpress博客以及踩坑记录,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
首先前提准备
1.安装docker,这个到菜鸟教程里面就可以搜索到安装教程
2.安装python3环境,因为centos中预装了python2,所以需要下载重新配置下
3.docker安装wordpress的.yml文件
内容:
1.安装docker
2.centos7环境下安装python3环境
2.1 安装
2.1.1 、安装依赖环境
2.1.2 安装pip,用pip装wget
2.1.3 wget下载安装包
2.1.4 编译安装
2.1.5 建立python3的软链接
2.2 部分坑记录
2.2.1
3.docker安装wordpress的.yml文件
3.1 docker-compose安装
3.2 最后 docker-compose.yml文件
更新 补充:
问题1:docker-compose无法安装,docker-compose version命令不存在
cd /usr/local/bin/wget https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-Linux-x86_64rename docker-compose-Linux-x86_64 docker-compose docker-compose-Linux-x86_64chmod +x /usr/local/bin/docker-compose
参考:https://blog.csdn.net/countofdane/article/details/95206131
问题2:安装docker-compose过程中报错
报错内容ERROR: Command errored out with exit status 1: command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zItSn5/pycparser/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zItSn5/pycparser/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info cwd: /tmp/pip-install-zItSn5/pycparser/ Complete output (17 lines): Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-zItSn5/pycparser/setup.py", line 65, in cmdclass={'install': install, 'sdist': sdist}, File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup _setup_distribution = dist = klass(attrs) File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__ _Distribution.__init__(self,attrs) File "/usr/lib64/python2.7/distutils/dist.py", line 287, in __init__ self.finalize_options() File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_options ep.load()(self, ep.name, value) File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2341, in load return self.resolve() File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2351, in resolve raise ImportError(str(exc)) ImportError: 'module' object has no attribute 'check_specifier' ----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法:sudo pip install --upgrade pipsudo pip install --upgrade setuptools
参考: https://www.cnblogs.com/liubiaos/p/9444485.html https://blog.csdn.net/liuyunshengsir/article/details/79136379
-----------------------更新分割线---------------------------------
1.安装docker
在菜鸟教程官网有下载教程,搜索即可https://www.runoob.com/docker/docker-compose.html 或者看我写的一个教程 https://blog.csdn.net/weixin_42245375/article/details/103447571
2.centos7环境下安装python3环境
部分小命令整理:1.Linux系统下如何查看当前所处目录位置 #pwd2.centos7更新pip版本 pip install --upgrade pip
2.1 安装
2.1.1 、安装依赖环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2.1.2 安装pip,用pip装wget
yum -y install epel-releaseyum install python-pip#安装pippip install wget #安装wget
2.1.3 wget下载安装包
sudo mkdir /usr/local/python3 # 创建安装目录wget --no-check-certificate https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz #下载文件tar -xzvf Python-3.7.0.tgz # 解压cd Python-3.7.0 #进入
2.1.4 编译安装
sudo ./configure --prefix=/usr/local/python3 # 指定创建的目录sudo make && sudo make install
2.1.5 建立python3的软链接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
**备注:**关于建立软链接这部分,我是这个写法,其他博主也有说直接软链接到默认的python的,那样为防止对yum有影响,需要修改yum配置文件,如下
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python修改 yum 配置文件sudo vi /usr/bin/yum将第一行指定的 python 版本改为 python2.7(#!/usr/bin/python 改为 #!/usr/bin/python2.7)vi /usr/libexec/urlgrabber-ext-down
2.2 部分坑记录
2.2.1
解决也很简单,但是一开始没想到,我们单独装这个 more-itertools 库,装 5.0.0 版本就好。
pip install more-itertools==5.0.0
再次执行安装最新版本
pip install sentry
3.docker安装wordpress的.yml文件
3.1 docker-compose安装
pip install docker-compose
3.2 最后 docker-compose.yml文件
文件内容:
version: '3.3'services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpressvolumes: db_data: {}
进入该文件所在目录,一行命令运行
docker-compose up -d
最后通过浏览器访问url:ip:8000即可访问博客主页
完成。。
上述就是小编为大家分享的如何在centos7中使用docker建立wordpress博客以及踩坑记录了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。