欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網
          最全最豐富的資訊網站

          docker-composer快速構建nginx+php環(huán)境

          本文由composer教程欄目給大家介紹怎么使用docker-composer構建一個簡單nginx+php環(huán)境,希望對需要的朋友有所幫助!

          目錄結構

          ?  Study tree ├── conf ├── docker-compose.yaml ├── nginx │   ├── conf │   │   └── laravel.conf │   └── html │       └── index.php

          index.php

          <?php /**  * Created by OrangBus  * User email: orangbus40400@gmail.com  * website: orangbus.cn  * blog: doc.orangbus.cn  * github: github.com/orangbus  */echo phpinfo();

          nginx.conf

          server {  listen       80;  server_name  localhost;   location / {  root   /usr/share/nginx/html;  index  index.html index.htm index.php;  }   error_page   500 502 503 504  /50x.html;  location = /50x.html {  root   /usr/share/nginx/html;  }   location ~ .php$ {  fastcgi_pass   php8:9000;  fastcgi_index  index.php;  fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;  include        fastcgi_params;  }}

          重點說明

          fastcgi_pass   php8:9000;

          php8: php容器的名稱,如果你想配置多個php版本,只需要將php的配置復制一份就可以,填寫對應的php容器名稱

           php8: # php的容器名稱  image: php:8.0-fpm  restart: always  volumes:  - ./nginx/html:/html--------------------------------  php74: # 對應的nginx配置文件為:fastcgi_pass   php74:9000;  image: php:8.0-fpm  restart: always  volumes:  - ./nginx/html:/html
          fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;

          /html :php項目映射到 【php 容器的目錄】(紅色)

          docker-compose

          version: '3.5'services:  nginx:  image: nginx:latest restart: always ports:  - 8010:80  volumes:  - ./nginx/html/:/usr/share/nginx/html # 注意點一  - ./nginx/conf/:/etc/nginx/conf.d/ links:  - php8 php8:  image: php:8.0-fpm restart: always volumes:  - ./nginx/html:/html #注意點二

          注意點一:

          ./nginx/html :本機你的php項目地址

          /usr/share/nginx/html: nginx默認的訪問地址

          注意點二:

          ./nginx/html :本機你的php項目地址

          /html: 這里地址是將你本地的php代碼映射到php的容器當中,一般是和你nginx配置的地址是一致的 (紅色)

          Tip:請留意兩處紅色的區(qū)域的關聯,這樣一個簡單的nginx+php關聯的環(huán)境就配置成功了。

          踩坑指南:

          當使用-link 時,連接容器的自定義端口將失效,舉例

          version: '3.5'services:  php8:  image: php:8.0-fpm restart: always volumes:  - ./nginx/html:/html links: # 如果使用 links ,當我們php程序中填寫mysql端口的時候應該是 3306 而不是 3307,但是我們外部是需要用3307端口去連接mysql的  - mysql mysql:  image: mysql:latest ports:  - 3307:3306

          贊(0)
          分享到: 更多 (0)
          網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號