99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

怎么用docker-composer快速構建nginx+php環境

這篇文章主要介紹“怎么用docker-composer快速構建nginx+php環境”,在日常操作中,相信很多人在怎么用docker-composer快速構建nginx+php環境問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用docker-composer快速構建nginx+php環境”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

陽信網站制作公司哪家好,找成都創新互聯!從網頁設計、網站建設、微信開發、APP開發、成都響應式網站建設公司等網站項目制作,到程序開發,運營維護。成都創新互聯從2013年成立到現在10年的時間,我們擁有了豐富的建站經驗和運維經驗,來保證我們的工作的順利進行。專注于網站建設就選成都創新互聯

目錄結構

?  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:請留意兩處紅色的區域的關聯,這樣一個簡單的nginx+php關聯的環境就配置成功了。

踩坑指南:

當使用-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

到此,關于“怎么用docker-composer快速構建nginx+php環境”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注創新互聯網站,小編會繼續努力為大家帶來更多實用的文章!

本文標題:怎么用docker-composer快速構建nginx+php環境
文章出自:http://www.yijiale78.com/article36/gjhssg.html

成都網站建設公司_創新互聯,為您提供網站設計公司商城網站ChatGPT動態網站響應式網站網站收錄

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都網站建設