<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # docker-compose搭建lnmp #### **先決條件** * 首先需要安裝docker * 安裝docker-compost ## 1、創建lnmp工作目錄 ~~~shell #創建三個目錄 mkdir lnmp && cd lnmp mkdir -p nginx/conf php mysql/data lnmp/www #編寫nginx 配置文件 nginx/conf/default.conf vim nginx/conf/default.conf server { listen 80; root /usr/share/nginx/html; index index.html index.htm index.php; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location / { index index.html index.htm index.php ; try_files $uri $uri/ /index.php?$query_string; autoindex on; } location ~ \.php$ { #php73是容器命名 fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; } } ~~~ ## 2、編寫php鏡像文件Dockerfile 因為php需要安裝一些擴展文件 使用dockerfile進行鏡像構建 ~~~dockerfile vim php/Dockerfile # 基礎 FROM php:7.2-fpm # 修改時區 ENV TZ Asia/Shanghai RUN date -R # 換源 RUN echo 'deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free' >/etc/apt/sources.list RUN echo 'deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free' >>/etc/apt/sources.list RUN apt-get update --fix-missing && apt-get install -y libpng-dev libjpeg-dev libfreetype6-dev \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include --with-jpeg-dir=/usr/include/jpeg \ && docker-php-ext-install gd mysqli opcache pdo_mysql gd zip ENV PHPREDIS_VERSION 5.0.1 ENV PHPXDEBUG_VERSION 2.6.0 ENV PHPSWOOLE_VERSION 4.5.10 RUN pecl install redis-$PHPREDIS_VERSION \ && pecl install xdebug-$PHPXDEBUG_VERSION \ && pecl install swoole-$PHPSWOOLE_VERSION \ && docker-php-ext-enable redis xdebug swoole RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ && php composer-setup.php \ && php -r "unlink('composer-setup.php');" \ && mv composer.phar /usr/local/bin/composer \ && composer config -g repo.packagist composer https://packagist.phpcomposer.com RUN apt-get install -y git RUN rm -rf /var/cache/apt/* \ && rm -rf /var/lib/apt/lists/* RUN mkdir /var/lib/sessions \ && chmod o=rwx -R /var/lib/sessions #容器啟動時執行指令 CMD ["php-fpm"] ~~~ ## 3、創建compose 的yml文件 ~~~yaml version: "3.9" services: #配置nginx nginx: #鏡像名稱 nginx:latest image: nginx #自定義容器的名稱 #container_name: c_nginx ports: - "80:80" #lnmp目錄和容器的/usr/share/nginx/html目錄進行綁定,設置rw權限 #將宿主機的~/lnmp/nginx/conf/default.conf和容器的/etc/nginx/conf.d/default.conf進行綁定 volumes: - ./data/:/usr/share/nginx/html:rw - ./nginx/conf/default.conf:/etc/nginx/conf.d/default.conf #設置環境變量,當前的時區 environment: TZ: "Asia/Shanghai" #容器是否隨docker服務啟動重啟 restart: always #容器加入名為lnmp的網絡 networks: - lnmp #配置php php: #image: php:7.4-fpm //由于php擴展比較多 直接build自己的Dockerfile 不需要官方鏡像 build: ./php container_name: php volumes: - ./data/:/var/www/html/:rw restart: always cap_add: - SYS_PTRACE networks: - lnmp #配置mysql mysql: image: mysql:latest ports: - "3306:3306" volumes: - ./mysql/data/:/var/lib/mysql/:rw restart: always networks: - lnmp #設置密碼 environment: MYSQL_ROOT_PASSWORD: "123456" TZ: :"Asia/Shanghai" networks: lnmp: ~~~ ## 4、執行compose命令 ~~~shell #構建鏡像環境 docker-compose up # -d 為后臺執行 ~~~ ## 5、擴展命令 ~~~shell docker-compose ps 查看compose服務 docker-compose run web env #查看web服務的環境變量 docker-compose stop 停止服務 docker-compose down #關閉并刪除改服務容器 #傳遞--volumnes同時刪除使用的數據卷 ~~~ ## 6、php7.4 dockerfile ~~~dockerfile FROM php:7.4-fpm # 設置時區 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 換源(國內源) #RUN echo 'deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free' >/etc/apt/sources.list #RUN echo 'deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free' >>/etc/apt/sources.list # 更新安裝依賴包和PHP核心拓展 RUN apt-get update && apt-get install -y \ libfreetype6-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd mysqli opcache pdo_mysql #7.4添加zip擴展有問題 #RUN apk add libzip-dev && docker-php-ext-install zip ENV PHPREDIS_VERSION 5.0.1 ENV PHPXDEBUG_VERSION 3.1.3 ENV PHPSWOOLE_VERSION 4.8.7 RUN pecl install redis-$PHPREDIS_VERSION \ && pecl install xdebug-$PHPXDEBUG_VERSION \ && pecl install swoole-$PHPSWOOLE_VERSION \ && docker-php-ext-enable redis xdebug swoole # 安裝 Composer ENV COMPOSER_HOME /root/composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer ENV PATH $COMPOSER_HOME/vendor/bin:$PATH CMD ["php-fpm"] WORKDIR /var/www/html ~~~ #### 當前構造的鏡像地址。可直接使用 無需再次構造 ~~~shell docker pull fangsinan/php:7.4 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看