• Docker 用centos 编译安装apache


    Docker 用centos 编译安装apache

    前提条件: 安装docker
    如果想安装docker请查阅:安装docker

    环境准备:centos8

    1. 拉取centos镜像
    [root@lvs docker]# docker pull centos:8
    8: Pulling from library/centos
    a1d0c7532777: Pull complete 
    Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
    Status: Downloaded newer image for centos:8
    docker.io/library/centos:8
    [root@lvs docker]# docker images
    REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
    centos       8         5d0da3dc9764   2 years ago    231MB
    
    [root@lvs ~]# docker run --name ttq6 -it centos
    Unable to find image 'centos:latest' locally
    latest: Pulling from library/centos
    Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
    Status: Downloaded newer image for centos:latest
    [root@ce7828597669 /]# ls
    bin  etc   lib	  lost+found  mnt  proc  run   srv  tmp  var
    dev  home  lib64  media       opt  root  sbin  sys  usr
    [root@ce7828597669 /]# 
    
    
    2. 进入容器操作
    
    # 编译安装apache
    [root@ce7828597669 ~]# cd /etc/yum.repos.d/
    [root@ce7828597669 yum.repos.d]# rm -rf *
    [root@ce7828597669 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
    [root@ce7828597669 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    [root@ce7828597669 yum.repos.d]# yum clean all
    [root@ce7828597669 yum.repos.d]# yum makecache
    [root@ce7828597669 ~]# groupadd -r apache
    [root@ce7828597669 ~]# useradd -r -M -s /sbin/nologin -g apache apache
    [root@ce7828597669 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool
    [root@ce7828597669 ~]# yum -y install gcc gcc-c++
    [root@ce7828597669 src]# wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz
    [root@ce7828597669 src]#  wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
    [root@ce7828597669 src]# wget http://archive.apache.org/dist/httpd/httpd-2.4.57.tar.gz
    [root@ce7828597669 src]# ls 
    apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  debug	httpd-2.4.57.tar.gz  kernels
    [root@ce7828597669 src]# tar xf apr-1.7.4.tar.gz 
    [root@ce7828597669 src]# tar xf apr-util-1.6.3.tar.gz 
    [root@ce7828597669 src]# tar xf httpd-2.4.57.tar.gz 
    [root@ce7828597669 src]# ls
    apr-1.7.4	  apr-util-1.6.3	 debug	       httpd-2.4.57.tar.gz
    apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  httpd-2.4.57  kernels
    [root@ce7828597669 src]# cd apr-1.7.4
    [root@ce7828597669 apr-1.7.4]# sed -i '/$RM "$cfgfile"/d' configure
    [root@ce7828597669 apr-1.7.4]# ./configure --prefix=/usr/local/apr
    [root@ce7828597669 apr-1.7.4]# make && make install
    [root@ce7828597669 src]# cd apr-util-1.6.3
    [root@ce7828597669 apr-util-1.6.3]#  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    [root@ce7828597669 apr-util-1.6.3]#  make && make install
    
    [root@ce7828597669 httpd-2.4.57]# cd httpd-2.4.57
    ./configure --prefix=/usr/local/apache --sysco-with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
    
    [root@ce7828597669 httpd-2.4.57]# make && make install
    [root@ce7828597669 ~]#  echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh                              
    [root@ce7828597669 ~]# source /etc/profile.d/httpd.sh
    [root@ce7828597669 ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
    [root@ce7828597669 ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
    [root@ce7828597669 ~]# sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf
    [root@ce7828597669 ~]# apachectl start
    [root@ce7828597669 ~]# ss -antl
    State   Recv-Q  Send-Q     Local Address:Port     Peer Address:Port  Process  
    LISTEN  0       128              0.0.0.0:80            0.0.0.0:*              
    [root@lvs ~]# curl 172.17.0.2
    

    It works!

    [root@lvs ~]# [root@lvs ~]# docker commit -p ttq6 //创建 sha256:ac2cf0f87374d4726a2e7b3631fbe0af711c965fcdeb3e2ec4c52cbd90d25fdd [root@lvs ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ac2cf0f87374 15 seconds ago 745MB httpd latest 7f6a969e81a5 31 hours ago 168MB centos 8 5d0da3dc9764 2 years ago 231MB centos latest 5d0da3dc9764 2 years ago 231MB [root@lvs ~]# [root@lvs ~]# docker tag ac2cf0f87374 ttq6/ttq6:v0.1 [root@lvs ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ttq6/ttq6 v0.1 ac2cf0f87374 2 minutes ago 745MB httpd latest 7f6a969e81a5 32 hours ago 168MB centos 8 5d0da3dc9764 2 years ago 231MB centos latest 5d0da3dc9764 2 years ago 231MB [root@lvs ~]# [root@lvs ~]# docker login Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one. You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/ Username: 这里输入你容器的账号及密码 Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded [root@lvs ~]# docker push ttq6/ttq6:v0.1
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
  • 相关阅读:
    机房管理技能,医疗行业必备!
    APO的全面进化之路(2):走向IBP、建设端到端供应链计划体系
    软考高级-系统架构师-软件架构设计练习题
    卡尔曼滤波应用在数据处理方面的应用
    View绘制流程-Vsync信号是如何发送和接受的
    计算机毕业设计django基于python商品比价平台(源码+系统+mysql数据库+Lw文档)
    咬文嚼图式的介绍二叉树、B树/B-树
    ES6解析赋值
    “中式汉堡”塔斯汀圈粉受众的秘诀是什么?
    优化3种教学方法
  • 原文地址:https://blog.csdn.net/m0_74939224/article/details/134242207