u1jodi1q 发表于 2024-10-4 13:14:53

运用php:7.4-fpm-buster镜像安排PHP7+Nginx环境


    <h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 介绍</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">1.1 介绍</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">前面福哥<span style="color: black;">已然</span>教给<span style="color: black;">大众</span><span style="color: black;">运用</span>php:7.4-apache-buster<span style="color: black;">基本</span>镜像搭建PHP运行环境了,这个是以模块方式(Module)运行PHP程序的,相比较这种方式<span style="color: black;">更加多</span>人会<span style="color: black;">选取</span>主流的以FastCGI方式运行PHP程序,以FastCGI方式运行PHP程序就要用到PHP的FPM服务(FastCGI Process Manager)了。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">今天福哥就带着<span style="color: black;">大众</span><span style="color: black;">运用</span>php:7.4-fpm-buster<span style="color: black;">基本</span>镜像来搭建以FastCGI方式运行PHP程序的环境。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">1.2 环境</span></strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;">
      <div style="color: black; text-align: left; margin-bottom: 10px;">
            <div style="color: black; text-align: left; margin-bottom: 10px;">
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">镜像版本</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">php:7.4-fpm-buster</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">操作系统</span></span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">CentOS 7 x86_64 2003</span></span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">服务器</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">TFCentOS7x64</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">IP</span></span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">192.168.168.68</span></span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">端口</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">80</span></span></p>
            </div>
      </div>
    </div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 安装</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1 Dockerfile</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.1 <span style="color: black;">基本</span>镜像</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">福哥<span style="color: black;">选取</span>的是php:7.4-fpm-buster这个<span style="color: black;">基本</span>镜像,这个<span style="color: black;">便是</span>FastCGI方式的。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">https://hub.docker.com/_/php/tags?page=1&amp;name=7.4-fpm-buster</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/4f34accdc04c4816aa437f0d052c8c82~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=z7UhHVJikOx6FzwsclAaXg67nqY%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">此刻</span>hub.docker.com依然打不开,<span style="color: black;">大众</span>就选这个版本吧!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">拉取镜像php:7.4-fpm-buster,添加到registry.tongfu.net:5000私有仓库里面。</p><span style="color: black;">docker</span>&nbsp;<span style="color: black;">pull</span>&nbsp;<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>
    <span style="color: black;">docker</span>&nbsp;<span style="color: black;">tag</span>&nbsp;<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>&nbsp;<span style="color: black;">registry</span><span style="color: black;">.tongfu</span><span style="color: black;">.net</span><span style="color: black;">:5000</span>/<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>
    <span style="color: black;">docker</span>&nbsp;<span style="color: black;">rmi</span>&nbsp;<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>
    <span style="color: black;">docker</span>&nbsp;<span style="color: black;">images</span>&nbsp;|&nbsp;<span style="color: black;">grep</span>&nbsp;<span style="color: black;">php</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/a179a38f35ba489782dd2edd3a8978f0~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=atSHnEG2MylRPfj2ytY93CaZWU4%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.2 创建镜像目录</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">创建镜像目录php7.4nginx并切换到php7.4nginx目录下面。</p>mkdir&nbsp;/tongfu.net/<span style="color: black;">data</span>/dockerfile/tfphp7<span style="color: black;">.4</span>nginx
    cd&nbsp;/tongfu.net/<span style="color: black;">data</span>/dockerfile/tfphp7<span style="color: black;">.4</span>nginx<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/041660a59d214cbe8726c95ff7619f2b~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=rPFVZOmL42I91fC5H5pa0NlqMPg%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.3 依赖镜像</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">第1</span>行写上依赖镜像php:7.4-fpm-buster。</p><span style="color: black;">FROM</span>&nbsp;<span style="color: black;">registry</span><span style="color: black;">.tongfu</span><span style="color: black;">.net</span><span style="color: black;">:5000</span>/<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.4 <span style="color: black;">守护</span>者信息</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这是福哥写的<span style="color: black;">守护</span>者信息。</p>#&nbsp;<span style="color: black;">for</span>&nbsp;<span style="color: black;">MAINTAINER</span>
    <span style="color: black;">MAINTAINER</span>&nbsp;<span style="color: black;">Author</span>:&nbsp;<span style="color: black;">Andy</span>&nbsp;<span style="color: black;">Bogate</span>
    <span style="color: black;">MAINTAINER</span>&nbsp;<span style="color: black;">Email</span>:&nbsp;<span style="color: black;">tongfu</span><span style="color: black;">@tongfu</span>.net
    MAINTAINER&nbsp;Home&nbsp;<span style="color: black;">page:</span>&nbsp;<span style="color: black;">https:</span>//tongfu.net
    MAINTAINER<span style="color: black;">Datetime:</span>&nbsp;<span style="color: black;">2023</span>/<span style="color: black;">03</span>/<span style="color: black;">18</span>
    MAINTAINER&nbsp;<span style="color: black;">Version:</span>&nbsp;v1.<span style="color: black;">0</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.5 暴露端口</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">供给</span>服务的端口<span style="color: black;">一般</span><span style="color: black;">状况</span>下是80和443,<span style="color: black;">咱们</span>把它们暴露出来。</p><span style="color: black;">#&nbsp;for&nbsp;EXPOSE</span>
    <span style="color: black;">EXPOSE</span>&nbsp;<span style="color: black;">80</span>&nbsp;<span style="color: black;">443</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.6 主目录</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">福哥设置镜像的主目录是/tongfu.net/web。</p><span style="color: black;">#&nbsp;for&nbsp;WORKDIR</span>
    <span style="color: black;">WORKDIR</span>&nbsp;/tongfu.net/web<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.7 设置时区</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">默认时区是UTC,<span style="color: black;">咱们</span>把它改成CST,<span style="color: black;">亦</span><span style="color: black;">便是</span>中国标准时间。</p><span style="color: black;">#&nbsp;for&nbsp;timezone</span>RUN&nbsp;ln&nbsp;-sf&nbsp;/usr/share/zoneinfo/Asia/Shanghai&nbsp;/etc/localtime&nbsp;\
    &amp;&amp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">"Asia/Shanghai"</span>&nbsp;&gt;&nbsp;/etc/timezone<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.8 安装工具和依赖库</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">后面的制作过程需要用到wget工具,这个需要<span style="color: black;">经过</span>apt-get安装一下。除此之外还要安装<span style="color: black;">有些</span>依赖库,<span style="color: black;">包含</span>图形库、zip和xml等等。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>镜像本身<span style="color: black;">仅有</span>一个FPM服务,FPM服务只能处理php程序,要处理其他类型的文件还得需要安装Nginx服务。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>后面要是ps命令检测服务健康状态,<span style="color: black;">因此</span>还需要安装procps服务。</p><span style="color: black;">#&nbsp;install&nbsp;wget&nbsp;&amp;&nbsp;nginx</span>
    RUN&nbsp;apt-get&nbsp;<span style="color: black;">update</span>&nbsp;\
    &amp;&amp;&nbsp;apt-<span style="color: black;">get</span>&nbsp;-y&nbsp;<span style="color: black;">install</span>wget&nbsp;vim&nbsp;nginx&nbsp;procps
    RUN&nbsp;apt-<span style="color: black;">get</span>&nbsp;-y&nbsp;<span style="color: black;">install</span>&nbsp;libwebp-dev&nbsp;libjpeg-dev&nbsp;libpng-dev&nbsp;libfreetype6-dev
    RUN&nbsp;apt-<span style="color: black;">get</span>&nbsp;-y&nbsp;<span style="color: black;">install</span>&nbsp;libzip-dev
    RUN&nbsp;apt-<span style="color: black;">get</span>&nbsp;-y&nbsp;<span style="color: black;">install</span>&nbsp;libc-<span style="color: black;">client</span>-dev&nbsp;libkrb5-dev
    RUN&nbsp;apt-<span style="color: black;">get</span>&nbsp;-y&nbsp;<span style="color: black;">install</span>&nbsp;libxml2-dev<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.9 释放PHP源码</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这个php:7.4-fpm-buster<span style="color: black;">包括</span>了PHP的源码,<span style="color: black;">由于</span>后面需要<span style="color: black;">运用</span>PHP源码安装PHP扩展,<span style="color: black;">因此</span>先要释放PHP源码。</p><span style="color: black;">#&nbsp;extract&nbsp;PHP&nbsp;source</span>
    <span style="color: black;">RUN</span>&nbsp;docker-php-source&nbsp;extract<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.10 GD图形库扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">GD图形库<span style="color: black;">能够</span>让<span style="color: black;">咱们</span><span style="color: black;">经过</span>PHP直接加工<span style="color: black;">各样</span><span style="color: black;">照片</span>文件,这个库<span style="color: black;">能够</span>用来实现<span style="color: black;">照片</span>验证码、照片加工等等功能的。</p><span style="color: black;">#&nbsp;gd&nbsp;extension</span>
    RUN&nbsp;docker-php-ext-configure&nbsp;gd&nbsp;\
    <span style="color: black;">--with-jpeg=/usr/include&nbsp;\</span>
    <span style="color: black;">--with-freetype=/usr/include/&nbsp;\</span>
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;gd&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;gd<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.11 MySQL扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">福哥是<span style="color: black;">运用</span>PDO来连接MySQL数据库,而MySQL的PDO库PHP资源包里<span style="color: black;">包括</span>了,只要安装起来就行了。</p><span style="color: black;">#&nbsp;extension&nbsp;of&nbsp;mysqli&nbsp;for&nbsp;MySQL</span>
    RUN&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;mysqli&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;mysqli

    <span style="color: black;">#&nbsp;extension&nbsp;of&nbsp;PDO&nbsp;for&nbsp;MySQL</span>
    RUN&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;pdo_mysql&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;pdo_mysql<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.12 Memcached扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">memcached库需要从PECL下载,福哥<span style="color: black;">选取</span>的是3.1.5版本,<span style="color: black;">这儿</span>直接<span style="color: black;">经过</span>phpize编译后就<span style="color: black;">能够</span>通过make安装了。memcached库依赖libmemcached库,福哥<span style="color: black;">选取</span>的是1.0.18版本,<span style="color: black;">尽可能</span>不要改避免版本冲突~</p><span style="color: black;">#&nbsp;library&nbsp;of&nbsp;Memcached</span>
    <span style="color: black;">RUN&nbsp;wget&nbsp;https</span>:<span style="color: black;">//launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz&nbsp;\
      &amp;&amp;&nbsp;tar&nbsp;-xzvf&nbsp;libmemcached-1.0.18.tar.gz&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;libmemcached-1.0.18&nbsp;\
      &amp;&amp;&nbsp;sed&nbsp;-i&nbsp;s/opt_servers&nbsp;\=\=&nbsp;false/\!opt_servers/g&nbsp;clients/memflush.cc&nbsp;\
      &amp;&amp;&nbsp;./configure&nbsp;\
      &amp;&amp;&nbsp;make&nbsp;&amp;&amp;&nbsp;make&nbsp;install&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;../&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-f&nbsp;libmemcached-1.0.18.tar.gz&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-rf&nbsp;libmemcached-1.0.18</span>
    <span style="color: black;">
      #&nbsp;extension&nbsp;of&nbsp;Memcached</span>
    <span style="color: black;">RUN&nbsp;wget&nbsp;http</span>:<span style="color: black;">//pecl.php.net/get/memcached-3.1.5.tgz&nbsp;\
      &amp;&amp;&nbsp;tar&nbsp;-xzvf&nbsp;memcached-3.1.5.tgz&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;memcached-3.1.5&nbsp;\
      &amp;&amp;&nbsp;/usr/local/bin/phpize&nbsp;\
      &amp;&amp;&nbsp;./configure&nbsp;--with-php-config=/usr/local/bin/php-config&nbsp;\
      --disable-memcached-sasl&nbsp;\
      &amp;&amp;&nbsp;make&nbsp;&amp;&amp;&nbsp;make&nbsp;install&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;../&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-f&nbsp;memcached-3.1.5.tgz&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-rf&nbsp;memcached-3.1.5&nbsp;\
      &amp;&amp;&nbsp;docker-php-ext-enable&nbsp;memcached</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.13 Redis扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">redis库需要从PECL下载,福哥<span style="color: black;">选取</span>的是4.1.0版本,<span style="color: black;">这儿</span>直接<span style="color: black;">经过</span>phpize编译后就<span style="color: black;">能够</span><span style="color: black;">经过</span>make安装了。</p><span style="color: black;">#&nbsp;extension&nbsp;of&nbsp;Redis</span>
    <span style="color: black;">RUN&nbsp;wget&nbsp;http</span>:<span style="color: black;">//pecl.php.net/get/redis-4.1.0.tgz&nbsp;\
      &amp;&amp;&nbsp;tar&nbsp;-xzvf&nbsp;redis-4.1.0.tgz&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;redis-4.1.0&nbsp;\
      &amp;&amp;&nbsp;/usr/local/bin/phpize&nbsp;\
      &amp;&amp;&nbsp;./configure&nbsp;--with-php-config=/usr/local/bin/php-config&nbsp;\
      &amp;&amp;&nbsp;make&nbsp;&amp;&amp;&nbsp;make&nbsp;install&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;../&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-f&nbsp;redis-4.1.0.tgz&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-rf&nbsp;redis-4.1.0&nbsp;\
      &amp;&amp;&nbsp;docker-php-ext-enable&nbsp;redis</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.14 MongoDB扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">MongoDB库需要从PECL下载,福哥<span style="color: black;">选取</span>的是1.7.4版本,<span style="color: black;">这儿</span>直接<span style="color: black;">经过</span>phpize编译后就<span style="color: black;">能够</span><span style="color: black;">经过</span>make安装了。</p><span style="color: black;">#&nbsp;extension&nbsp;of&nbsp;MongoDB</span>
    <span style="color: black;">RUN&nbsp;wget&nbsp;http</span>:<span style="color: black;">//pecl.php.net/get/mongodb-1.7.4.tgz&nbsp;\
      &amp;&amp;&nbsp;tar&nbsp;-xzvf&nbsp;mongodb-1.7.4.tgz&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;mongodb-1.7.4&nbsp;\
      &amp;&amp;&nbsp;/usr/local/bin/phpize&nbsp;\
      &amp;&amp;&nbsp;./configure&nbsp;--with-php-config=/usr/local/bin/php-config&nbsp;\
      &amp;&amp;&nbsp;make&nbsp;&amp;&amp;&nbsp;make&nbsp;install&nbsp;\
      &amp;&amp;&nbsp;cd&nbsp;../&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-f&nbsp;mongodb-1.7.4.tgz&nbsp;\
      &amp;&amp;&nbsp;rm&nbsp;-rf&nbsp;mongodb-1.7.4&nbsp;\
      &amp;&amp;&nbsp;docker-php-ext-enable&nbsp;mongodb</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.15 其他扩展</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">除了前面安装的几个扩展之外,福哥还安装了imap、zlib、soap、bcmath这些扩展,<span style="color: black;">意见</span><span style="color: black;">大众</span><span style="color: black;">亦</span>把这些安装上。</p><span style="color: black;">#&nbsp;imap&nbsp;extension</span>
    RUN&nbsp;docker-php-ext-configure&nbsp;imap&nbsp;\
    <span style="color: black;">--with-kerberos&nbsp;\</span>
    <span style="color: black;">--with-imap-ssl&nbsp;\</span>&amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;imap&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;imap

    <span style="color: black;">#&nbsp;zlib&nbsp;extension</span>RUN&nbsp;mv&nbsp;/usr/src/php/ext/zlib/config0.m4&nbsp;/usr/src/php/ext/zlib/config.m4&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;zlib&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;zlib

    <span style="color: black;">#&nbsp;soap&nbsp;extension</span>
    RUN&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;soap&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;soap

    <span style="color: black;">#&nbsp;bcmath&nbsp;extension</span>
    RUN&nbsp;docker-php-ext-<span style="color: black;">install</span>&nbsp;bcmath&nbsp;\
    &amp;&amp;&nbsp;docker-php-ext-<span style="color: black;">enable</span>&nbsp;bcmath<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.1.16 清理PHP源码</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>PHP的扩展都<span style="color: black;">根据</span>好了,<span style="color: black;">已然</span>不需要源码了,清理掉吧。</p><span style="color: black;">#&nbsp;source&nbsp;delete</span>RUN&nbsp;docker-php-source<span style="color: black;">delete</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.2 多进程</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">福哥今天制作的镜像是基于FastCGI方式运行的,<span style="color: black;">这儿</span>面有FPM和Nginx两个服务,<span style="color: black;">亦</span><span style="color: black;">便是</span>说<span style="color: black;">运用</span>这个镜像<span style="color: black;">起步</span>的容器里面就会运行两个进程。<span style="color: black;">然则</span><span style="color: black;">根据</span>Docker的设计思想一个容器里只能跑一个进程,怎么办?</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">其实按PHP的FastCGI方式的设计,应该是<span style="color: black;">起步</span>两个容器<span style="color: black;">一起</span>处理用户的请求。静态内容由Nginx容器负责处理,PHP程序由FPM容器负责处理。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">然则</span>福哥不想弄<span style="color: black;">那样</span>麻烦,就想把FPM服务和Nginx服务放在<span style="color: black;">一块</span>!要实现这个目的,就需要修改镜像的ENTRYPOINT。一个ENTRYPOINT只能运行一个进程,为<span style="color: black;">认识</span>决这个问题,福哥要自定义这个ENTRYPOINT,用ENTRYPOINT<span style="color: black;">起步</span>一个Shell脚本,在Shell脚本里面<span style="color: black;">同期</span><span style="color: black;">起步</span>FPM服务和Nginx服务。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下面是福哥写的一个ENTRYPOINT<span style="color: black;">起步</span>Shell脚本start_service,用来<span style="color: black;">同期</span><span style="color: black;">起步</span>FPM服务和Nginx服务。</p><span style="color: black;">#!/bin/sh
    </span>
    <span style="color: black;">#&nbsp;argv</span>

    <span style="color: black;">#&nbsp;functions</span>

    <span style="color: black;">function</span>_main
    {<span style="color: black;">#&nbsp;start&nbsp;fpm</span>
    &nbsp;&nbsp;/usr/<span style="color: black;">local</span>/sbin/php-fpm&nbsp;-D

    &nbsp;&nbsp;<span style="color: black;">#&nbsp;start&nbsp;nginx</span>
    &nbsp;&nbsp;/usr/sbin/nginx

    &nbsp;&nbsp;<span style="color: black;">#&nbsp;wait&nbsp;secs</span>
    &nbsp;&nbsp;sleep&nbsp;6s

    &nbsp;&nbsp;<span style="color: black;">#&nbsp;service</span>
    &nbsp;&nbsp;<span style="color: black;">while</span>&nbsp;[&nbsp;1&nbsp;]&nbsp;;
    &nbsp;&nbsp;<span style="color: black;">do</span>
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;[&nbsp;<span style="color: black;">""</span>&nbsp;=&nbsp;<span style="color: black;">"`ps&nbsp;-ef&nbsp;|&nbsp;grep&nbsp;-v&nbsp;grep&nbsp;|&nbsp;grep&nbsp;php-fpm:&nbsp;master&nbsp;process`"</span>&nbsp;]&nbsp;;&nbsp;<span style="color: black;">then</span>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">"php&nbsp;is&nbsp;down"</span>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">exit</span>&nbsp;1
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">fi</span>

    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">if</span>&nbsp;[&nbsp;<span style="color: black;">""</span>&nbsp;=&nbsp;<span style="color: black;">"`ps&nbsp;-ef&nbsp;|&nbsp;grep&nbsp;-v&nbsp;grep&nbsp;|&nbsp;grep&nbsp;nginx:&nbsp;master&nbsp;process`"</span>&nbsp;]&nbsp;;&nbsp;<span style="color: black;">then</span>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">echo</span>&nbsp;<span style="color: black;">"nginx&nbsp;is&nbsp;down"</span>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">exit</span>&nbsp;2
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">fi</span>

    &nbsp;&nbsp;&nbsp;&nbsp;sleep&nbsp;6s
    &nbsp;&nbsp;<span style="color: black;">done</span>
    }

    <span style="color: black;">#&nbsp;main</span>

    _main&nbsp;<span style="color: black;">"<span style="color: black;">$@</span>"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在创建新的镜像的时候把start_service配置文件拷贝进去,并且授权可执行权限,最后将ENTRYPOINT的命令改成start_service。</p><span style="color: black;">#&nbsp;entry&nbsp;point</span>
    <span style="color: black;">COPY</span>start_service&nbsp;/usr/sbin/start_service
    RUN&nbsp;chmod&nbsp;+x&nbsp;/usr/sbin/start_service
    ENTRYPOINT&nbsp;[<span style="color: black;">"/usr/sbin/start_service"</span>,&nbsp;<span style="color: black;">""</span>]<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.3 php配置文件</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.3.1 php.ini</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">php.ini的存放目录是/usr/local/etc/php/,镜像<span style="color: black;">供给</span>了php-ini-development、php.ini-production两个配置文件模板,<span style="color: black;">咱们</span><span style="color: black;">能够</span><span style="color: black;">按照</span><span style="color: black;">运用</span>场景<span style="color: black;">选取</span><span style="color: black;">研发</span>版本还是生产版本。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">起步</span>临时容器,从容器里复制php.ini-development出来放到镜像目录下。</p><span style="color: black;">docker</span>&nbsp;<span style="color: black;">run</span>&nbsp;<span style="color: black;">-tid</span>&nbsp;<span style="color: black;">--name</span>&nbsp;<span style="color: black;">ttt</span>&nbsp;<span style="color: black;">-h</span>&nbsp;<span style="color: black;">ttt</span>&nbsp;<span style="color: black;">registry</span><span style="color: black;">.tongfu</span><span style="color: black;">.net</span><span style="color: black;">:5000</span>/<span style="color: black;">php</span><span style="color: black;">:7.4-fpm-buster</span>
    <span style="color: black;">docker</span>&nbsp;<span style="color: black;">cp</span>&nbsp;<span style="color: black;">ttt</span>:/<span style="color: black;">usr</span>/<span style="color: black;">local</span>/<span style="color: black;">etc</span>/<span style="color: black;">php</span>/<span style="color: black;">php</span><span style="color: black;">.ini-development</span>&nbsp;<span style="color: black;">php</span><span style="color: black;">.ini</span>
    <span style="color: black;">docker</span>&nbsp;<span style="color: black;">rm</span>&nbsp;<span style="color: black;">-f</span>&nbsp;<span style="color: black;">ttt</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c7e786006f9b4a869c85cabfa46c5775~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=ADPzWWvzfI3fGOudeGtRkKJY4%2F8%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">设置错误日志路径,将PHP的执行错误存起来。</p><span style="color: black;">error_log</span>=&nbsp;/tmp/php_errors.log<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/bbbb36b520cd4777af8ec17c3606eebd~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=niHK6PM53KU40e7cXgET5418iVU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">修改php.ini设置时区为Asia/Shanghai。</p><span style="color: black;">date.timezone</span>&nbsp;=&nbsp;Asia/Shanghai<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/dfde45649a614aa5b33e2a4d76576e7d~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=Mh4verinOR0m3rAAMtqajaZ674s%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">复制php.ini覆盖镜像里面的php.ini配置文件。</p><span style="color: black;">#&nbsp;php.ini</span>
    COPY&nbsp;php.ini&nbsp;/usr/<span style="color: black;">local</span>/etc/php/php.ini<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.4 nginx配置文件</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.4.1 模块配置</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">镜像安装的nginx<span style="color: black;">包含</span>modules-available和modules-enabled两个模块配置目录,modules-available里面<span style="color: black;">包括</span><span style="color: black;">所有</span>的可用模块配置文件,modules-enabled里面是启用的模块配置文件。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要启用模块就从modules-available<span style="color: black;">选取</span>模块配置文件移动到modules-enabled下面。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要停用模块就从modules-enabled<span style="color: black;">选取</span>模块配置文件移动回modules-available下面。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>nginx默认就支持rewrite,这个模块就<span style="color: black;">不消</span><span style="color: black;">调节</span>了!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.4.2 站点配置</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">镜像安装的nginx<span style="color: black;">包含</span>sites-available和sites-enabled两个站点配置目录,sites-available里面<span style="color: black;">包括</span><span style="color: black;">所有</span>的可用站点配置文件,sites-enabled里面是启用的站点配置文件。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要启用站点就从sites-available<span style="color: black;">选取</span>站点配置文件<span style="color: black;">创立</span>符号链接到sites-enabled下面。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">要停用站点就将sites-enabled下面删除站点配置文件的符号链接。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>镜像的nginx服务是福哥<span style="color: black;">经过</span>apt-get安装的,加上nginx的默认站点的配置文件default里面有<span style="color: black;">非常多</span>示例的配置乱七八糟的,<span style="color: black;">因此</span><span style="color: black;">这儿</span>福哥打算自己写一个精简版本的默认站点配置文件default。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">福哥在默认站点的server里面利用rewrite实现了一个PHP的伪静态重定向配置,<span style="color: black;">能够</span>将<span style="color: black;">各样</span>html请求转交给htmlRouteMap.php处理。</p><span style="color: black;">server</span>&nbsp;{
    &nbsp;&nbsp;&nbsp;<span style="color: black;">listen</span>&nbsp;<span style="color: black;">80</span>&nbsp;default_server;
    &nbsp;&nbsp;&nbsp;<span style="color: black;">listen</span>&nbsp;[::]:<span style="color: black;">80</span>&nbsp;default_server;

    &nbsp;&nbsp;&nbsp;<span style="color: black;">server_name</span>&nbsp;_;

    &nbsp;&nbsp;&nbsp;<span style="color: black;">rewrite</span><span style="color: black;">&nbsp;^\/(.*)\.html</span>/htmlRouteMap.php?tfphp_static_name=<span style="color: black;">$1</span>;

    &nbsp;&nbsp;&nbsp;<span style="color: black;">location</span>&nbsp;/&nbsp;{
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">root</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/var/www/html;
    &nbsp;&nbsp;&nbsp;}

    &nbsp;&nbsp;&nbsp;<span style="color: black;">location</span>&nbsp;<span style="color: black;">~&nbsp;\.php$</span>&nbsp;{
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">client_body_buffer_size</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">1m</span>;

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">root</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/var/www/html;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">fastcgi_pass</span>localhost:<span style="color: black;">9000</span>;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">fastcgi_index</span>&nbsp;&nbsp;index.php;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">fastcgi_param</span>&nbsp;&nbsp;SCRIPT_FILENAME&nbsp;&nbsp;<span style="color: black;">$document_root</span><span style="color: black;">$fastcgi_script_name</span>;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">include</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fastcgi_params;
    &nbsp;&nbsp;&nbsp;}
    }<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在创建新的镜像的时候把default配置文件拷贝进去。</p><span style="color: black;">#&nbsp;nginx&nbsp;sites</span>
    COPY&nbsp;<span style="color: black;">default</span>&nbsp;/etc/nginx/sites-enabled/<span style="color: black;">default</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">2.5 创建镜像</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>下面的命令创建tfphp:7.4-nginx-1.0.0镜像。</p><span style="color: black;">docker</span>&nbsp;<span style="color: black;">build</span>&nbsp;<span style="color: black;">-f</span>&nbsp;<span style="color: black;">Dockerfile</span>&nbsp;\
    <span style="color: black;">-t</span>&nbsp;<span style="color: black;">registry</span><span style="color: black;">.tongfu</span><span style="color: black;">.net</span><span style="color: black;">:5000</span>/<span style="color: black;">tfphp</span><span style="color: black;">:7.4-nginx-1.0.0</span>&nbsp;./<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/96076d7e69894b558eb1d448b31de2df~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=QFiGLBO6JsUPvcDJsOqde1VMYz4%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">查看镜像</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">瞧瞧</span>新的镜像,<span style="color: black;">此刻</span>有apache版本、nginx版本两个tfphp的镜像了。</p><span style="color: black;">docker</span>&nbsp;images&nbsp;|&nbsp;grep&nbsp;tfphp<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/8a8b7e738a804f148975a8b2c9fe12a6~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=4VNUKqKmPC5ahVhGoCnqpy2mJFM%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">3. 测试</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">3.1 程序目录和程序文件</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">既然都是php环境,<span style="color: black;">那样</span><span style="color: black;">运用</span>tfphp:7.4-apache-1.0.0的测试代码就<span style="color: black;">能够</span>了!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">3.2 删除容器</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>前面<span style="color: black;">咱们</span><span style="color: black;">运用</span>apache版本的tfphp<span style="color: black;">起步</span>了一个容器了,<span style="color: black;">此刻</span>要测试nginx版本的tfphp就需要先把这个tfphp容器删除掉。</p><span style="color: black;">docker</span>&nbsp;rm&nbsp;-f&nbsp;tfphp<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/bccc69ae457b442e9732ccbf2a3e5761~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=kcKBReW3%2Bk9Yuhlv2rANV%2BVy5TU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">3.3 <span style="color: black;">起步</span>容器</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>下面的命令基于tfphp:7.4-nginx-1.0.0镜像<span style="color: black;">起步</span>一个容器,将80端口和443端口映射到宿主机上面,将/var/www/html这个nginx主目录映射到前面<span style="color: black;">创立</span>的目录上面。</p>docker&nbsp;run&nbsp;-tid&nbsp;\
    <span style="color: black;">--name&nbsp;tfphp&nbsp;\</span>
    <span style="color: black;">-h&nbsp;tfphp&nbsp;\</span>
    <span style="color: black;">-p&nbsp;80:80&nbsp;\</span>
    <span style="color: black;">-p&nbsp;443:443&nbsp;\</span>
    <span style="color: black;">-v&nbsp;/tongfu.net/data/docker/data/tfphp/html:/var/www/html&nbsp;\</span>
    registry.tongfu.net:5000/tfphp:7.4-nginx-1.0.0<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c00887e7cba449519697778a1f5dbc45~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=BsrhTLunm%2FvLyoNGuvHeKC1gwYU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">3.4 浏览器<span style="color: black;">拜访</span></span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开浏览器<span style="color: black;">拜访</span><span style="color: black;">http://192.168.168.68/index.php</span>,<span style="color: black;">能够</span>看到PHP系统信息。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">能够</span>看到Server API一栏的信息是FPM/FastCGI,证明<span style="color: black;">咱们</span>的这个运行环境是FastCGI模式的。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/414e3f98d7e746339f1f3f3fbcbca24f~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=WWDubxuqYbqdG%2F6I1DjFtkcVl8w%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">输入网址<span style="color: black;">http://192.168.168.68/tongfu.net/docker/tfphp.html</span>,<span style="color: black;">能够</span>看到请求html资源路径被htmlRouteMap.php打印出来了。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/d44899a98e2a4f53b26b172952ddd861~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728208245&amp;x-signature=%2B6B0Z9hOPTaDMOZ8sT2iqLLg2vE%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">4. 总结</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">今天福哥在TFCentOS7x64服务器上面<span style="color: black;">经过</span>Dockerfile创建了一个镜像tfphp:7.4-nginx-1.0.0,并且<span style="color: black;">经过</span>这个新创建的镜像tfphp:7.4-nginx-1.0.0<span style="color: black;">起步</span>了一个容器,这个镜像用来运行基于PHP语言<span style="color: black;">研发</span>的应用程序。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">后面福哥会在这个镜像tfphp:7.4-nginx-1.0.0<span style="color: black;">基本</span>之上进行二次扩展制作新的镜像,<span style="color: black;">而后</span><span style="color: black;">按照</span>镜像的用途针对nginx和php进行自定义的配置,敬请期待~</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">https://m.tongfu.net/home/35/blog/513983.html</p>




7wu1wm0 发表于 2024-10-23 19:46:11

“板凳”(第三个回帖的人)‌

1fy07h 发表于 2024-10-28 08:35:05

论坛外链网http://www.fok120.com/
页: [1]
查看完整版本: 运用php:7.4-fpm-buster镜像安排PHP7+Nginx环境