【问题标题】:Installing mod_jk in centos 7 on docker for windows在 docker for windows 上的 centos 7 中安装 mod_jk
【发布时间】:2018-02-20 10:17:41
【问题描述】:

我在https://github.com/Paritosh-Anand/Docker-Httpd-Tomcat@987654321 中尝试了 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

【问题讨论】:

  • 强烈建议您改用 AJP。离题。

标签: docker centos docker-compose centos7


【解决方案1】:

对于 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

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 1970-01-01
    • 2020-06-20
    • 2021-05-10
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    相关资源
    最近更新 更多