gpt4 book ai didi

docker - 在 docker for windows 上的 centos 7 中安装 mod_jk

转载 作者:行者123 更新时间:2023-12-04 19:43:11 26 4
gpt4 key购买 nike

我在 https://github.com/Paritosh-Anand/Docker-Httpd-Tomcat 中尝试了 Apache for ubuntu in Docker (Docker for windows)

Dockerfile 是

FROM ubuntu:latest

MAINTAINER <user>@<domain>.com

RUN apt-get update && apt-get install -y --no-install-recommends apache2 libapache2-mod-jk

ADD apache2.conf /etc/apache2/apache2.conf

ADD 000-default.conf /etc/apache2/sites-enabled/000-default.conf

ADD worker.properties /etc/libapache2-mod-jk/workers.properties

ADD jk.conf /etc/apache2/mods-available/jk.conf

VOLUME ["/var/log/apache2"]

EXPOSE 80 443

CMD ["apachectl", "-k", "start", "-DFOREGROUND"]

但是,我需要在 CentOs 7 中运行 Apache,而不是在 ubuntu 中。所以我将 Dockerfile 更改为
FROM centos:7

MAINTAINER <user>@<domain>.com

RUN yum -y --setopt=tsflags=nodocs update
RUN yum -y --setopt=tsflags=nodocs install httpd
RUN yum -y --setopt=tsflags=nodocs install mod-jk
RUN yum clean all

ADD apache2.conf /etc/apache2/apache2.conf

ADD 000-default.conf /etc/apache2/sites-enabled/000-default.conf

ADD worker.properties /etc/libapache2-mod-jk/workers.properties

ADD jk.conf /etc/apache2/mods-available/jk.conf

VOLUME ["/var/log/apache2"]

EXPOSE 80 443

CMD ["apachectl", "-k", "start", "-DFOREGROUND"]

在运行时,我收到错误
Step 5/13 : RUN yum -y --setopt=tsflags=nodocs install mod-jk
---> Running in a98487a9509c
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.nhanhoa.com
* extras: mirrors.nhanhoa.com
* updates: mirror.ehost.vn
No package mod-jk available.
Error: Nothing to do
ERROR: Service 'httpd' failed to build: The command '/bin/sh -c yum -y --setopt=tsflags=nodocs install mod-jk' returned a non-zero code: 1

这是镜子的问题吗?如何在操作系统为 CentOs 7 的 docker 中安装 mod_jk?
我的主机操作系统是 windows 10

最佳答案

对于 centos 7,您需要从源代码编译模块。以下面的 Dockerfile 为例

FROM centos:7

RUN yum -y update && yum clean all
RUN yum -y install httpd httpd-devel gcc* make && yum clean all

# Install mod_jk
RUN curl -SL http://mirror.sdunix.com/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz -o tomcat-connectors-1.2.40-src.tar.gz \
&& mkdir -p src/tomcat-connectors \
&& tar xzf tomcat-connectors-1.2.40-src.tar.gz -C src/tomcat-connectors --strip-components=1 \
&& cd src/tomcat-connectors/native/ \
&& ./configure --with-apxs=/usr/bin/apxs \
&& make \
&& cp apache-2.0/mod_jk.so /usr/lib64/httpd/modules/ \
&& ./libtool --finish /usr/lib64/httpd/modules/ \
&& cd / \
&& rm -rf src/ \
&& rm -f tomcat-connectors-1.2.40-src.tar.gz


# mod_jk conf files
ADD mod_jk.conf /etc/httpd/conf.d/
ADD workers.properties /etc/httpd/conf.d/

EXPOSE 80

# Simple startup script to avoid some issues observed with container restart
ADD run-httpd.sh /run-httpd.sh
RUN chmod -v +x /run-httpd.sh

CMD ["/run-httpd.sh"]

取自 https://github.com/maeharin/apache-tomcat-docker-sample/blob/master/docker/httpd/Dockerfile

关于docker - 在 docker for windows 上的 centos 7 中安装 mod_jk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46168128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com