您现在的位置是:首页 > cms教程 > WordPress教程WordPress教程
docker怎么搭建wordpress网站
乐萱2025-03-20WordPress教程已有人查阅
导读一、 创建nginx镜像二、创建mariadb镜像三、关联容器3.1 关闭web容器3.2 测试web能否访问mariadb四、安装wordpress4.1 安装4.2 数据库配置
Version: 1.0
实验环境
系统:CentOS Linux release 7.2.1511
内核:Linux C7 3.10.0-327.el7.x86_64
软件源 163+epel
数据库名:wordpress
用户名:wordpress
密码:wordpress
数据库主机:db
表前缀:wp_
提交
4.4 创建wp-config.php
web中的内容复制内贴到wp-config.php
点击install
cat /renn/myweb/wp-config.php
实验环境
系统:CentOS Linux release 7.2.1511
内核:Linux C7 3.10.0-327.el7.x86_64
软件源 163+epel
yum -y install wget vim
cd /etc/yum.repos.d/
rm -f ./*
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
cd /etc/pki/rpm-gpg/
wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
rpm --import RPM-GPG-KEY-EPEL-7
yum clean all
yum makecache
# docker version
Client:
Version: 1.12.6
API version: 1.24
Package version: docker-common-1.12.6-16.el7.centos.x86_64
Go version: go1.7.4
Git commit: 3a094bd/1.12.6
Built: Fri Apr 14 13:46:13 2017
OS/Arch: linux/amd64
一、 创建nginx镜像
mkdir docker
cd docker
cat Dockerfile
FROM centos:centos7
MAINTAINER woodman
RUN yum -y install wget
RUN rm -f /etc/yum.repos.d/*
RUN wget http://mirrors.163.com/.help/CentOS7-Base-163.repo && mv CentOS7-Base-163.repo /etc/yum.repos.d/163.repo
RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN cd /etc/pki/rpm-gpg/
RUN wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
RUN rpm -import RPM-GPG-KEY-EPEL-7
RUN yum clean all
RUN yum install httpd php php-mysql php-mbstring -y && yum clean all
EXPOSE 80
CMD [“/usr/sbin/httpd”,”-f”,”/etc/httpd/conf/httpd.conf”,”-DFOREGROUND”]
#创建
docker build -f Dockerfile -t web:centos7 .
二、创建mariadb镜像
#cat Dockerfile
FROM centos:centos7
MAINTAINER woodman
RUN yum -y install wget
RUN rm -f /etc/yum.repos.d/*
RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN cd /etc/pki/rpm-gpg/
RUN wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
RUN rpm --import RPM-GPG-KEY-EPEL-7
RUN wget http://mirrors.163.com/.help/CentOS7-Base-163.repo && mv CentOS7-Base-163.repo /etc/yum.repos.d/163.repo
RUN yum clean all
RUN yum install mariadb-server openssh-server -y && yum clean all
RUN mysql_install_db && chown -R mysql:mysql /var/lib/mysql/
VOLUME /var/lib/mysql/
ADD mysql.sh /mysql.sh
RUN chmod 755 /mysql.sh
EXPOSE 22
EXPOSE 3306
CMD ["/mysql.sh"]
cat mysql.sh
#!/bin/bash
# Author:woodman
mysqld_safe &
sleep 5
mysqladmin -uroot password '123456'
mysql -uroot -p123456 -e "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123456';FLUSH PRIVILEGES;"
sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config && ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
echo 123456 | passwd --stdin root
/usr/sbin/sshd -D
docker build -f Dockerfile -t mariadb:centos7 .
docker run -d -p 22222:22 -v /var/mysql:/var/lib/mysql --name db mariadb:centos7
三、关联容器3.1 关闭web容器
docker stop web
docker rm web
3.2 测试web能否访问mariadb
#docker run -it -p 80:80 -v /var/web/:/var/ /html/ --link=db --name=web web:centos7 /bin/bash
#yum -y install mariadb
#mysql -uroot -p123456 -h db
#exit; exti ; docker rm web
#docker run -d -p 80:80 -v /var/web/:/var/ /html/ --link=db:todb --name=web web:centos7
四、安装wordpress4.1 安装
wget https://cn.wordpress.org/wordpress-4.7.3-zh_CN.tar.gz
tar -zxf latest.tar.gz
cp -a wordpress/* /var/web
4.2 数据库配置
ssh 192.168.1.7 -p 22222
mysql -uroot -p123456
MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'wordpress'@'%' IDENTIFIED BY 'wordpress';
MariaDB [(none)]> FLUSH PRIVILEGES;
>exit;
#exit;
4.3 设置 wordpress
docker run -ti --rm -v /var/web/:/var/ /html/ --entrypoint="/bin/bash" web:centos7 -c "ls -ln /var/ /html"
docker run -ti --rm --entrypoint="/bin/bash" mariadb:centos7 -c "ls -ln /var/lib/mysql"
#文件属性显示一堆'?'
#setenforce 0
访问:http://x.x.x.x数据库名:wordpress
用户名:wordpress
密码:wordpress
数据库主机:db
表前缀:wp_
提交
4.4 创建wp-config.php
web中的内容复制内贴到wp-config.php
点击install
cat /renn/myweb/wp-config.php
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'wordpress');
/** MySQL hostname */
define('DB_HOST', 'db');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'zOf g^T@Fg~eZy,kEsstBc+=3DjY;F`.7MKtOd_J4?`0tKv.r7B,cyHTC(c<L^pb');
define('SECURE_AUTH_KEY', '?4a! VG;6DZwO_^aEm9%7zz=eV;O141za] NRk,vs0Zk#y{!ZMxveWa*?!=Lk34(');
define('LOGGED_IN_KEY', 'y@9@FV2EEX[g2FmENZ4sB{)k:x+W3{x?o1-K}$;UkzA @)IGzY6x[TaK?ninGkg:');
define('NONCE_KEY', 'EC95aN/5-hQUK%1t<UK6$BlS=ngt=eT>3m_h she31E5.8O&O;V5z`j6R71nCW>1');
define('AUTH_SALT', '@xSzJTwfL^<7HJG8i`7:@Y1.$vT[0}AD,(:B:Emb`H142P4]P2*/y`V>nex94>et');
define('SECURE_AUTH_SALT', 'f*4R2&WrJd{XcL][Jn9#RM$1aLTzp1A1a|cj+$6?2^,W&|`t#4n7VL|n(=V1:,P_');
define('LOGGED_IN_SALT', '*62i~DFK~&b8b#%UaZZiC72)W=$i;I`ZyU2w<_+Cb>ubVP/.J~i]a
define('NONCE_SALT', 'Caf6?g(]8b r@[pq9c4r,elRW_eZQE{oq!w_8,xd/qa`D[zMb-Pc!em_?}t:nVnx');
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
本文标签:
很赞哦! ()
相关教程
图文教程
WordPress路径URL伪静态设置方法
WordPress中默认的URL为动态的,为了优化需要将其设置为固定链接。通过WordPress后台,设置---固定连接,选择自定义结构,我设置的是 /%post_id%.html,设置完之后,在前台浏览时
apache服务器server介绍和安装配置WordPress
1、apache server 是一个流行的http服务器。对应的可执行软件是httpd 和 apachectl。httpd提供http服务,apachectl控制httpd的执行。2、CGI 即 Common Gateway Interface,
wordpress优缺点分析
最近比较忙,老板安排这个项目安排那个项目还是之前没接触过得东西,今天写一点关于现在手上的项目搭建软件,wordpress以下简称WP。说到WP可能很多新朋友和我一样以前都没有结
修改WordPress中已有头像的方法
如何修改 WordPress 的默认 Gravatar 头像,也就是说,如果访客有自己的Gravatar头像就显示自己的,如果没有就显示网站指定的。WordPress默认的头像自定义修改成功!
相关源码
-
WordPress主题模板主题巴巴/博客X主题源码免费下载博客X主题专注于内容创作领域,为博客、资讯类网站提供专业的内容展示解决方案。该模板采用精心设计的布局结构,能够有效提升内容的可读性和用户停留时间。查看源码 -
(自适应响应式)绿色环保防腐木材轻钢别墅建材pbootcms模板下载本模板为环保防腐木材、轻钢别墅建材类企业设计开发,基于PbootCMS内核构建,充分考虑了建材行业的展示需求与产品特点。模板设计风格自然环保,布局清晰合理,呈现建材产品特性与专业优势,帮助访客直观了解产品特点并建立信任感。查看源码 -
(自适应)餐具英文外贸生活用品带下载功能网站模板免费下载为餐具及生活用品外贸企业打造的响应式网站模板,基于PbootCMS内核开发。突出产品展示与多语言支持特性,通过自适应设计确保更好客户在手机、平板、电脑等设备上获得一致浏览体验。查看源码 -
(自适应)橙色家政服务清洁保洁服务pbootcms网站模板源码下载模板核心价值:基于PbootCMS内核开发的家政服务类网站模板,通过模块化设计展现服务项目、团队风采、服务案例等核心板块,突出时效预约、服务标准化展示等家政行业特性。查看源码 -
(PC+WAP)聚氨酯粉末涂料防腐耐用材料粘合剂网站源码下载为化工涂料企业设计的展示系统,集成产品技术参数库、颜色样板展示器和配方查询模块。支持粉末涂料、环氧树脂等多类产品分类展示查看源码 -
(自适应响应式)HTML5简繁双语电子元器件设备制造Pbootcms模板下载本模板为电子科技设备制造、电子元件生产等高科技企业设计,采用PbootCMS内核开发,具备简繁双语切换功能。模板设计充分考虑了电子科技行业的技术展示需求,能够专业呈现各类电子元器件、电路板、智能设备的参数规格和应用方案。查看源码
| 分享笔记 (共有 篇笔记) |

