1.保存成 Dockerfile 文件
FROM ubuntu
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean \
&& apt-get update \
&& apt-get upgrade -y
RUN apt-get install -y wget curl
RUN apt-get install -y pkg-config build-essential \
autoconf bison re2c libxml2-dev libsqlite3-dev libcurl4-gnutls-dev \
libjpeg-dev libpng-dev libmcrypt-dev libreadline6-dev libfreetype6-dev \
libtidy-dev libtool valgrind openssl libssl-dev libzip-dev libwebp-dev \
libxpm-dev
RUN cd /var/tmp/ \
&& wget -c http://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz \
&& tar -zxvf oniguruma-6.9.4.tar.gz \
&& cd oniguruma-6.9.4/ \
&& ./autogen.sh \
&& ./configure \
&& make -j6 \
&& make install
RUN cd /var/tmp/ \
&& wget -c http://github.com/php/php-src/archive/refs/tags/php-8.0.8.tar.gz \
&& tar -zxvf php-8.0.8.tar.gz \
&& cd php-src-php-8.0.8/ \
&& ./buildconf --force \
&& ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-rpath \
--enable-re2c-cgoto \
--enable-gcc-global-regs \
--enable-phpdbg \
--with-valgrind \
--enable-zts \
--with-openssl \
--with-zlib \
--enable-bcmath \
--enable-calendar \
--with-curl \
--enable-ftp \
--enable-gd \
--with-webp \
--with-jpeg \
--with-xpm \
--with-freetype \
--with-gettext \
--with-mhash \
--enable-intl \
--with-ldap-sasl \
--enable-mbstring \
--with-mysqli=mysqlnd \
--enable-pcntl \
--with-pdo-mysql=mysqlnd \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-tidy \
--enable-zend-test \
--with-zip \
--enable-mysqlnd \
--with-pear \
&& make -j6 \
&& make install \
&& ln -s /usr/local/php/sbin/* /usr/local/bin/ \
&& ln -s /usr/local/php/bin/* /usr/local/bin/ \
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
&& cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
&& groupadd www \
&& useradd -g www www \
&& php-fpm
2.编译成镜像
docker build -f ./Dockerfile t php8 .
如果需要nginx redis,可以吧下面的代码插入到上面的Dockefile 文件底部
RUN cd /var/tmp/ \
&& wget -c http://download.redis.io/releases/redis-6.2.4.tar.gz \
&& tar -xvf redis-6.2.4.tar.gz \
&& mv redis-6.2.4 redis \
&& cd redis \
&& make -j6 \
&& make install \
&& ln /usr/local/redis/bin/* /usr/local/bin
RUN cd /var/tmp/ \
&& wget -c http://nginx.org/download/nginx-1.17.3.tar.gz \
&& tar -zxvf nginx-1.17.3.tar.gz \
&& cd nginx-1.17.3 \
&& apt-get install -y libpcre3-dev aptitude zlib1g.dev \
&& ./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-file-aio \
--with-http_realip_module \
&& make -j6 \
&& make install \
&& ln /usr/local/nginx/sbin/nginx /usr/local/bin \
&& nginx
网友评论