基于容器搭建lnmp架构

该博客详细介绍了如何通过容器技术一步步拉取centos镜像,构建nginx、php和mysql镜像,从而搭建完整的LNMP架构。
摘要由CSDN通过智能技术生成

拉取centos镜像

[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete 
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
centos       latest    5d0da3dc9764   2 months ago   231MB

构建nginx镜像

[root@localhost ~]# docker run --name nginx -it centos
[root@3c7370935253 /]# useradd -r -M -s /sbin/nologin nginx
[root@3c7370935253 /]# yum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-devel 
[root@3c7370935253 /]# mkdir -p /var/log/nginx
[root@3c7370935253 /]# chown -R nginx.nginx /var/log/nginx
[root@3c7370935253 /]# cd /usr/src/
[root@3c7370935253 src]# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@3c7370935253 src]# tar xf nginx-1.20.1.tar.gz
[root@3c7370935253 src]# cd nginx-1.20.1
[root@3c7370935253 nginx-1.20.1]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@3c7370935253 nginx-1.20.1]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
[root@3c7370935253 nginx-1.20.1]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@3c7370935253 nginx-1.20.1]# source /etc/p
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值