Docker 搭建lnmp+wordpress镜像

news/2024/11/19 17:26:50/
#关闭防火墙,核心防护
systemctl stop firewalld
setenforce 0#创建自定义网络模式
docker network create --subnet=172.18.0.0/16 --opt "com.docker.network.bridge.name"="docker1" mynetwork#部署nginx(容器id 172.18.0.10)mkdir /opt/nginx
cd /opt/nginx#上传 nginx的安装包和 wordpress安装包 到 /opt/nginx#创建文件夹,存放wordpress
mkdir /opt/nginx/html
tar xf wordpress-4.9.4-zh_CN.tar.gz -C /opt/nginx/html#创建Dockerfile文件,创建文件之前,需要先准备centos基础镜像
vim DockerfileFROM centos:7
MAINTAINER this is nginx image <emmm>
RUN yum install pcre-devel zlib-devel gcc gcc-c++ make -y
RUN useradd -M -s /sbin/nologin nginx
ADD nginx-1.22.0.tar.gz /usr/local/src/
WORKDIR /usr/local/src/nginx-1.22.0
RUN ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module && make -j2 && make install
ENV PATH /usr/local/nginx/sbin:$PATH
ADD nginx.conf /usr/local/nginx/conf/
RUN chmod 777 -R /usr/local/nginx/html/
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]#创建镜像
docker build -t nginx:lnmp .#创建并运行容器
docker run -it --name nginx -p 80:80 -v /opt/nginx/html:/usr/local/nginx/html --net mynetwork --ip 172.18.0.10 nginx:lnmp

#部署mysql(172.18.0.20)mkdir /opt/mysqld
cd /opt/mysqld#上传 mysql压缩包到当前路径下vim DockerfileFROM centos:7
MAINTAINER this is mysql image <emmm>
RUN yum install  gcc gcc-c++ ncurses ncurses-devel bison cmake make -y
ADD mysql-boost-5.7.20.tar.gz /usr/local/src/
WORKDIR /usr/local/src/mysql-5.7.20/
RUN cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8  \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1 && make -j 4 && make install
ADD my.cnf /etc/
ENV PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
RUN useradd -M -s /sbin/nologin mysql
RUN chown mysql:mysql /etc/my.cnf
RUN chown -R mysql:mysql /usr/local/mysql/
RUN /usr/local/mysql/bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
EXPOSE 3306
CMD ["/usr/local/mysql/bin/mysqld"]#编写my.cnf配置文件
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock[mysql]
port = 3306
socket = /usr/local/mysql/mysql.sock[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES#创建镜像
docker build -t mysql:lnmp .#创建并启动镜像
docker run -d --name=mysql -v --privileged -v /usr/local/mysql --net mynetwork -ip 172.18.0.20 mysql:lnmpdocker run -it mysql bashmysql -uroot -p
create database wordpress;
grant all privileges on wordpress.* to 'wordpress'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%' identified by 'abc123';
flush privileges;

#搭建PHP(172.19.0.30)mkdir /opt/php
cd /opt/php#上传 php-7.1.10.tar.bz2 到 /opt/php 目录中vim DockerfileFROM centos:7
MAINTAINER this is php image <emmm>
RUN yum -y install gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel \
gcc gcc-c++ make pcre-devel
RUN useradd -M -s /sbin/nologin nginx
ADD php-7.1.10.tar.bz2 /usr/local/src/
WORKDIR /usr/local/src/php-7.1.10
RUN ./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip && make -j4 && make install
ENV PATH /usr/local/php/bin:/usr/local/php/sbin:$PATH
ADD php.ini /usr/local/php/lib/
ADD php-fpm.conf /usr/local/php/etc/
ADD www.conf /usr/local/php/etc/php-fpm.d/
EXPOSE 9000
ENTRYPOINT [ "/usr/local/php/sbin/php-fpm", "-F" ]#创建镜像并启动
docker build -t php:lnmp .
docker run --name=php -d -p 9000:9000 --volumes-from mysql --volumes-from nginx --net mynetwork --ip 172.19.0.30 php:lnmp

访问 192.168.94.7/wordpress/index.php

下面一步一步安装即可


http://www.ppmy.cn/news/1443676.html

相关文章

文件上传复习(upload-labs 6-13关)

Pass-06&#xff08;大小写绕过&#xff09; $is_upload false; $msg null; if (isset($_POST[submit])) {if (file_exists(UPLOAD_PATH)) {$deny_ext array(".php",".php5",".php4",".php3",".php2",".html"…

Android系统apk商城下载安装及安装认证源码分析

最终调用函数&#xff1a; installPackageWithVerificationAndEncryption 打印日志&#xff0c;看看安装轨迹&#xff1a; 代码流程如下&#xff1a; 行05729调用来这里了&#xff1a; 发送MCS_BOUND: 进入startCopy&#xff1a; 调用handleReturnCode&#xff1a; …

Spring Boot的启动过程深入了解

深入了解Spring Boot的启动过程不仅需要理论上的理解,结合代码示例更能直观地展现其实现细节。以下是一系列代码示例,配合文字说明,帮助您更深入地理解Spring Boot的启动过程: 一、Spring Boot启动入口 import org.springframework.boot.SpringApplication; import org.s…

【AI】Deepstream入门(2)Ubuntu20.04安装Deepstream

1、安装GPU驱动 本人显卡型号:RTX4060 Laptop(笔记本专用显卡) 【AI】惠普暗夜精灵9安装Ubuntu20.04+nvidia驱动 2、安装cuda、cuDNN 【AI】Ubuntu20.04安装cuda、cuDNN 3、安装TensorRT 1)下载 下载地址:https://docs.nvidia.com/deeplearning/tensorrt/archives/i…

MemFire解决方案-物联网数据平台解决方案

方案背景 随着各种通讯、传感技术发展&#xff0c;数据通讯成本的急剧下降&#xff0c;数以万亿计的智能设备&#xff08;智能手环、智能电表、智能手机、各种传感器设备等&#xff09;接入网络&#xff0c;并源源不断的产生海量的实时数据。这些海量数据的价值挖掘&#xff0…

Java集合框架-Collection-List-vector(遗留类)

目录 一、vector层次结构图二、概述三、底层数据结构四、常用方法五、和ArrayList的对比 一、vector层次结构图 二、概述 Vector类是单列集合List接口的一个实现类。与ArrayList类似&#xff0c;Vector也实现了一个可以动态修改的数组&#xff0c;两者最本质的区别在于——Vec…

免费语音转文字:自建Whisper,贝锐花生壳3步远程访问

Whisper是OpenAI开发的自动语音识别系统&#xff08;语音转文字&#xff09;。 OpenAI称其英文语音辨识能力已达到人类水准&#xff0c;且支持其它98中语言的自动语音辨识&#xff0c;Whisper神经网络模型被训练来运行语音辨识与翻译任务。 此外&#xff0c;与其他需要联网运行…

FPGA 以太网概念简单学习

1 MAC和PHY 从硬件的角度来说&#xff0c;以太网接口电路主要由 MAC &#xff08; Media Access Control &#xff09;控制器和物理层接口 PHY&#xff08;Physical Layer &#xff0c; PHY &#xff09;两大部分构成。 MAC 指媒体访问控制子层协议&#xff0c;它和 PHY 接…