web出题踩坑:php-apache官方镜像

FROM php:7.4-apache
#RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY ./php.ini /usr/local/etc/php/php.ini
COPY ./source.list /etc/apt/sources.list
RUN apt-get update && \
    apt-get install -y default-mysql-server && \
    apt-get clean

RUN /usr/local/bin/docker-php-ext-install mysqli

RUN apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd


RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load


COPY www/ /var/www/html/
COPY mysql/ /etc/mysql/mariadb.conf.d/
COPY run.sh /run.sh

RUN apt-get install -y openssh-server && \
    service ssh start
COPY shadow /etc/
COPY sshd_config /etc/ssh/
COPY flag.txt /

RUN chmod +x /run.sh
ENTRYPOINT /run.sh && tail -F /var/log/apache2/access.log
EXPOSE 80 22

log

这个官方镜像把apache的日志链接到了标准输出,所以要查看日志是不能直接打开文件看的,而是可以用docker log containerID

安装扩展

Quick reference
贼麻烦,因为依赖要自己安,建议直接百度对应扩展的安装方式

要改apache配置也会比较麻烦,为了开rewrite,我是直接

RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

要改conf的话讲道理也可以直接cp一个准备好的进去,不过没试过

posted @ 2020-09-17 21:50  MustaphaMond  阅读(448)  评论(0编辑  收藏  举报