【Dockerfile镜像实例】构建LNMP环境并运行Wordpress网站平台

构建LNMP环境并运行Wordpress网站平台

一、项目背景和要求

公司在实际的生产环境中,需要使用Docker 技术在一台主机上创建LNMP服务并运行Wordpress网站平台。

然后对此服务进行相关的性能调优和管理工作

二、项目环境

主机 操作系统 IP地址
宿主机 CentOS 7.3 x86_64 192.168.210.104
Nginx容器 172.18.0.10
Mysql容器 172.18.0.20
Php容器 172.18.0.30

三、部署过程

(1) 创建自定义网络

#关闭防火墙和selinux
systemctl stop firewalld 
systemctl disable firewalld
setenforce 0
#创建自定义网络
docker network create --subnet=172.18.0.0/16 --opt "com.docker.network.bridge.name"="docker1"  mynetwork

在这里插入图片描述

(2) 部署Nginx

#创建工作目录并上传相关软件包
mkdir /opt/nginx
cd /opt/nginx

mkdir /opt/nginx/html
tar zxvf wordpress-4.9.4-zh_CN.tar.gz -C /opt/nginx/html

#创建nginx用户
useradd -M -s /sbin/nologin nginx 
#修改权限和属主属组
chmod -R 777 wordpress/
chown -R nginx:nginx wordpress/

在这里插入图片描述
在这里插入图片描述

#编写Dockerfile文件
vim Dockerfile

FROM centos:7

MAINTAINER this is nginx of LNMP <wyx 2024-01-26>

ADD nginx-1.24.0.tar.gz /opt/

RUN yum -y install pcre-devel zlib-devel openssl-devel gcc gcc-c++ make && \
    yum clean all && \
    useradd -M -s /sbin/nologin nginx && \
    cd /opt/nginx-1.24.0/ && \
    ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && \
    make && make install

ENV PATH $PATH:/usr/local/nginx/sbin

COPY nginx.conf /usr/local/nginx/conf/nginx.conf

EXPOSE 80
#EXPOSE 443

CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]

#编写配置文件nginx.conf
vim nginx.conf

#user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
   
    use epoll
    worker_connections  1024;
}


http {
   
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值