锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

基于容器编译安装做apache镜像

时间:2023-02-26 00:30:01 pcb传感器进口201a75

安装apache的软件包

[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz  --2022-04-27 14:36:38-- https://downloads.apache.org/apr/apr-1.7.0.tar.gz 主机正在分析中 downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ... 正在连接 downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... 已连接。 已发出 HTTP 请求,等待回应... 200 OK 长度:1093896 (1.0M) [application/x-gzip] 保存至: “apr-1.7.0.tar.gz”  [root@localhost ~]# docker pull centos //基于centos镜像安装 Using default tag: latest latest: Pulling from library/centos a1d0c7532777: Pulling fs layer  [root@localhost ~]# docker run -it --name c1 centos /bin/bash // 创建个容器 因为要在里面操作,所以要加-it 和/bin/bash [root@6ef3d6a933d9 /]# alias ls='ls --color' [root@6ef3d6a933d9 /]# ls // 让文件名有颜色 [root@localhost ~]# ls 公共  图片  音乐             apr-1.7.0.targz initial-setup-ks.cfg 模板 文档 桌面 apr-util-1.6.1.tar.gz 视频 下载 anaconda-ks.cfg httpd-2.4.53.tar.gz [root@localhost ~]# mkdir software [root@localhost ~]# mv *.gz software [root@localhost ~]# docker cp software/ c1:/usr/src [root@6ef3d6a933d9 /]# cd /usr/src/ [root@6ef3d6a933d9 src]# ls debug kernels [root@6ef3d6a933d9 src]# ls debug kernels software [root@6ef3d6a933d9 src]# cd software/ [root@6ef3d6a933d9 software]# tar xf apr-1.7.0.tar.gz  [root@6ef3d6a933d9 software]# tar xf apr-util-1.6.1.tar.gz  [root@6ef3d6a933d9 software]# tar xf httpd-2.4.53.tar.gz  [root@6ef3d6a933d9 software]# cd apr-1.7.0 [root@6ef3d6a933d9 apr-1.7.0]# vi configure cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile"//删掉这个 [root@6ef3d6a933d9 apr-1.7.0]# ./configure --prefix=/usr/local/apr //把他装到、usr/local/apr checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu Configuring APR library Platform: x86_64-pc-linux-gnu checking for working mkdir -p... yes APR Version: 1.7.0 checking for chosen layout... apr checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/usr/src/software/apr-1.7.0': //没有这个文件 configure: error: no acceptable C compiler found in $PATH See `config.log' for more details [root@6ef3d6a933d9 apr-1.7.0]# dnf clean all Failed to set locale, defaulting to C.UTF-8 0 files removed [root@6ef3d6a933d9 apr-1.7.0]# dnf makecache Failed to set locale, defaulting to C.UTF-8 CentOS Linux 8 - AppStream 83 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist // 不能下载 [root@6ef3d6a933d9 apr-1.7.0]# cat /etc/redhat-release CentOS Linux release 8.4.2105 //因为原装的centos是有问题的 [root@6ef3d6a933d9 software]# cd /etc/yum.repos.d/ [root@6ef3d6a933d9 yum.repos.d]# ls CentOS-Linux-AppStream.repo CentOS-Linux-FastTrack.repo CentOS-Linux-BaseOS.repo CentOS-Linux-HighAvailability.repo CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Media.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-Plus.repo CentOS-Linux-Devel.repo CentOS-Linux-PowerTools.repo CentOS-Linux-Extras.repo CentOS-Linux-Sources.repo [root@6ef3d6a933d9 yum.repos.d]# rm -rf * [root@6ef3d6a933d9 yum.repos.d]# cd [root@6ef3d6a933d9 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2495 100 2495 0 0 5435 0 --:--:-- --:--:-- --:--:-- 5435 [root@6ef3d6a933d9 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo [root@6ef3d6a933d9 ~]# ls anaconda-ks.cfg anaconda-post.log original-ks.cfg [root@6ef3d6a933d9 ~]# cd /etc/yum.repos.d/ [root@6ef3d6a933d9 yum.repos.d]# ls CentOS-Base.repo [root@6ef3d6a933d9 yum.repos.d]# //重新下载centos [root@6ef3d6a933d9 yum.repos.d]# dnf clean all Failed to set locale, defaulting to C.UTF-8 0 files removed [root@6ef3d6a933d9 yum.repos.d]# dnf makecache Failed to set locale, defaulting to C.UTF-8 CentOS-8.5.2111 - Base - mirrors.aliyun.com 866 kB/s | 4.6 MB 00:05 CentOS-8.5.2111 - Extras - mirrors.aliyun.com 30 kB/s | 10 kB 00:00 CentOS-8.5.2111 - AppStream - mirrors.aliyun.co 781 kB/s | 8.4 MB 00:11 Metadata cache created. [root@6ef3d6a933d9 yum.repos.d]# [root@6ef3d6a933d9 apr-1.7.0]# dnf -y install gcc make Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:03:46 ago on Wed Apr 27 07:20:47 2022. Dependencies resolved. ================================================================================ Package Arch Version Repository Size [root@6ef3d6a933d9 apr-1.7.0]# ./configure --prefix=/usr/local/apr checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu ./configure --prefix=/usr/local/apr checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu //成功 [root@6ef3d6a933d9 apr-1.7.0]# make [root@6ef3d6a933d9 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr [root@d5ba75d1e013 apr-util-1.6.1]#make [root@d5ba75d1e013 apr-util-1.6.1]# dnf -y install expat-devel [root@d5ba75d1e013 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make //安装过程省略 [root@d5ba75d1e013 apr-util-1.6.1]# make [root@d5ba75d1e013 apr-util-1.6.1]# make install [root@d5ba75d1e013 software]# cd apr-util-1.6.1 [root@d5ba75d1e013 apr-util-1.6.1]# make && make install [root@d5ba75d1e013 apr-util-1.6.1]# cd ../httpd-2.4.53/ [root@d5ba75d1e013 httpd-2.4.53]# ./configure --prefix=/usr/local/apache \ > --sysconfdir=/etc/httpd24 \ > --enable-so \ > --enable-ssl \ > --enable-cgi \ > --enable-rewrite \ > --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@d5ba75d1e013 httpd-2.4.53]# make && make install [root@d5ba75d1e013 httpd-2.4.53]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh [root@d5ba75d1e013 httpd-2.4.53]# source /etc/profile.d/httpd.sh [root@d5ba75d1e013 httpd-2.4.53]# ln -s /usr/local/apache/include /usr/include/apache [root@d5ba75d1e013 httpd-2.4.53]# exit exit [root@localhost ~]#  

制作镜像

[root@localhost ~]# docker commit -a 'sean <2902314105@qq.com>' -c 'CMD ["/usr/local/apache/bin/httpd","-X","-D","FOREGROUND"]' -p c1 httpd:v0.1
sha256:425486653d93a190323e863b084ed242a8952b9296b9f176d1c5a24f0ac29428

//删除所有的容器
```sql ```[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED       STATUS       PORTS     NAMES
d5ba75d1e013   centos    "/bin/bash"   3 hours ago   Up 3 hours             c1
[root@localhost ~]# docker rm -f c1
c1
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
 删除所有的容器准备测试镜像是否可使用
[root@localhost ~]# docker run -d --name httpd -p 80:80 httpd:v0.1 //创建容器不懂可以查看帮助文档
4ed60bf965ed17ed423bda17d7a57ed5b0c0b69f46740f6e97dbb01cd375ec0a
[root@localhost ~]# docker inspect httpd | grep IPAddress //看下这个容器的IP
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.2",
                    "IPAddress": "172.17.0.2",
[root@localhost ~]# curl 172.17.0.2 //在虚拟机中访问
<html><body><h1>It works!</h1></body></html>

在这里插入图片描述

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章