docker Nginx PHP-FPM單機(jī)多站點(diǎn)布署的方法
網(wǎng)上嘗試過(guò)各種方法,處理單機(jī)中單NGINX容器,單PHP-FPM容器布署多站點(diǎn),均無(wú)法成功。
經(jīng)過(guò)反思總結(jié),目前共實(shí)施兩種方法成功:
- 單Nginx,多PHP-FPM
- 單Nginx,單PHP-FPM
單Nginx,多PHP-FPM
docker-compose.yml
version: '2'
services:
nginx-1.15.1:
image: nginx:laster
ports:
- "80:80"
volumes:
- ./htdocs:/usr/local/nginx/html
- ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./etc/nginx/conf.d:/etc/nginx/conf.d
- ./log/nginx:/var/log/nginx
networks:
- leoedu-network
php-fpm-a:
image: php-fpm:laster
volumes:
- ./htdocs/a.com:/var/www/html
networks:
- leoedu-network
php-fpm-b:
image: php-fpm:laster
volumes:
- ./htdocs/b.com:/var/www/html
networks:
- leoedu-network
networks:
leoedu-network:
driver: bridge
nginx配置文件:
server {
listen 80;
charset utf-8;
server_name a.com;
root /usr/local/nginx/html/a.com;
index index.html index.htm index.php;
error_log /var/log/nginx/a.com-error.log;
access_log /var/log/nginx/a.com-access.log;
location ~ \.php$ {
fastcgi_pass php-fpm-a:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
單Nginx,單PHP-FPM
docker-compose.yml
version: '2'
services:
nginx-1.15.1:
image: nginx:laster
ports:
- "80:80"
volumes:
- ./htdocs:/usr/local/nginx/html
- ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./etc/nginx/conf.d:/etc/nginx/conf.d
- ./log/nginx:/var/log/nginx
networks:
- leoedu-network
php-fpm-7.2.5:
image: php-fpm:laster
volumes:
- ./htdocs:/var/www/html
networks:
- leoedu-network
networks:
leoedu-network:
driver: bridge
NGINX配置關(guān)鍵點(diǎn)在于:
astcgi_param SCRIPT_FILENAME /var/www/html/nick.com/$fastcgi_script_name;
具體原因,回頭有空補(bǔ)上,此篇純做記錄
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
docker compose部署cassandra集群的操作代碼
這篇文章主要介紹了docker compose部署cassandra集群的操作代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2024-03-03
Docker多個(gè)容器不能有相同端口號(hào)的處理方案
這篇文章主要介紹了Docker多個(gè)容器不能有相同端口號(hào)的處理方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-03-03
docker中使用mysql數(shù)據(jù)庫(kù)詳解(在局域網(wǎng)訪問(wèn))
這篇文章主要給大家介紹了在docker中使用mysql數(shù)據(jù)庫(kù),在局域網(wǎng)訪問(wèn)的相關(guān)資料,文中通過(guò)圖文以及示例代碼介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-06-06
Docker部署postgresql的方法實(shí)現(xiàn)
本文主要介紹了Docker部署postgresql的方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2025-01-01
通過(guò)docker容器搭建lamp架構(gòu)的流程
這篇文章主要介紹了dcoker容器搭建lamp架構(gòu),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
docker容器內(nèi)安裝TensorRT的問(wèn)題
很多朋友在使用docker容器內(nèi)安裝TensorRT的時(shí)候,遇到一大堆棘手的問(wèn)題,不知道怎么處理好了,今天小編就docker安裝TensorRT的問(wèn)題給大家詳細(xì)介紹下,感興趣的朋友一起看看吧2021-05-05

