Last active
November 21, 2021 14:27
-
-
Save fasthold/9529b7525a1765649a1d8b18c6e9af38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
WORKDIR /var/www/html | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list | |
RUN sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get install -y build-essential apt-utils curl software-properties-common g++ make git | |
RUN add-apt-repository ppa:ondrej/php -y | |
RUN apt-get update | |
RUN apt-get install -y apache2 | |
RUN apt-get install -y php7.4 php7.4-curl php7.4-gmp php7.4-intl php7.4-mbstring php7.4-opcache php7.4-pspell php7.4-xmlrpc php7.4-cli php7.4-imap php7.4-json php7.4-mysql php7.4-tidy php7.4-bz2 php7.4-common php7.4-dev php7.4-gd php7.4-xml php7.4-zip php7.4-bcmath | |
# RUN apt-get install -y php7.2 php7.2-curl php7.2-gmp php7.2-intl php7.2-mbstring php7.2-opcache php7.2-pspell php7.2-xmlrpc php7.2-cli php7.2-imap php7.2-json php7.2-mysql php7.2-tidy php7.2-bz2 php7.2-common php7.2-dev php7.2-gd php7.2-xml php7.2-zip php7.2-bcmath | |
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && \ | |
a2enmod rewrite | |
# install Composer | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
# change to aliyun mirror | |
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ | |
RUN php -a | |
# update php settings | |
RUN curl -sSLJO https://gitee.com/dockerpivot/php-apache/raw/master/php/php.custom.ini | |
RUN mv php.custom.ini /etc/php/7.4/apache2/conf.d | |
#COPY ./docker-init/index.php public/index.php | |
# update apache settings | |
RUN curl -sSLJO https://gitee.com/dockerpivot/php-apache/raw/master/apache/000-default.conf | |
RUN mv 000-default.conf /etc/apache2/sites-enabled/000-default.conf | |
RUN service apache2 restart | |
EXPOSE 80 | |
CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"] | |
##################### Usage: ####################### | |
# docker build -t php74-apache ./ | |
# docker run -it -d -p 8001:80 \ | |
# --mount type=bind,source=/home/fasthold/dev/projects/docker-php,target=/var/www/html \ | |
# --mount type=bind,source=/home/fasthold/dev/projects/docker-php,target=/var/log/apache2 \ | |
# php74-apache:latest | |
# docker exec -it xxxxxxxx bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment