这里主要是针对nginx和php安装的dockerfile的模版,本人已经测试过了,生成镜像后可以使用php服务和nginx服务,这里安装nginx是自动下载并编译。php使用的是yum安装,因为在下载安装的时候出现编译的插件都部分,没有安装到所以就不尝试了,后面有用到一个ImageMagick服务的安装,因为下载太慢就在本地下载后COPY进去了。看下面的代码吧。
FROM centos:7 RUN yum install -y curl && \ curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && \ yum clean all && \ yum remove oniguruma-devel -y && \ yum remove oniguruma -y && \ rpm -ivh http://rpmfind.net/linux/epel/7/x86_64/Packages/o/oniguruma-6.8.2-1.el7.x86_64.rpm RUN rpm -ivh https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-6.8.2-1.el7.x86_64.rpm RUN yum install -y cmake pcre pcre-devel gd gd-devel pcre pcre-devel \ zlib-devel git gcc gcc-c++ net-tools iproute telnet wget cur curl-devel\ wget vim libxml2 libxml2-devel openssl openssl-devel libjpeg-turbo \ libjpeg-turbo-devel libpng-devel libpng freetype-devel freetype icu GeoIP GeoIP-devel glibc make autoconf \ libicu-devel libicu libmcrypt libmcrypt-devel libxslt libxslt-devel php-mysql libsqlite3x-devel && \ rm -rf /var/cache/yum/* RUN wget http://nginx.org/download/nginx-1.12.2.tar.gz RUN tar xf nginx-1.12.2.tar.gz WORKDIR nginx-1.12.2 RUN useradd www -u 1200 -M -s /sbin/nologin && mkdir -p /usr/local/nginx && chown -R www.www /usr/local/nginx/ && chmod -R 755 /usr/local/nginx RUN ./configure --user=www --group=www --prefix=/usr/local/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module && make && make install RUN yum -y install epel-release RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm RUN yum-config-manager --enable remi-php73 RUN yum -y install php php-curl php-mysql php-fpm php-zip RUN yum -y install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel RUN yum -y install libwebp-devel libwebp-tools ADD ImageMagick-7.0.10-51.tar.gz /usr/local/ RUN mv /usr/local/ImageMagick-7.0.10-51 /usr/local/ImageMagick WORKDIR /usr/local/ImageMagick RUN ./configure --with-bzlib --with-autotrace --with-djvu --with-dps --with-fftw --with-flif --with-fpx --with-fontconfig --with-freetype --with-gslib --with-gvc --with-jbig --with-jpeg --with-jxl --with-png --with-raw --with-webp --with-xml --with-zlib --with-zstd && make && make install EXPOSE 80 443 9000 CMD /usr/local/php-7.3.29/sbin/php-fpm && /usr/local/nginx/sbin/nginx -g "daemon off;"
注意:这里需要启动两个服务分别是php-fpm和nginx,我们可以使用CMD也可以使用ENTRYPOINT,不过在这里都不建议,如果可以我们可以选择supervisor,只需要把配置文件做个映射就可以随便加服务。也可以写到脚本里。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏