Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of docker Nginx PHP-FPM stand-alone and Multi-site deployment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Various methods have been tried on the Internet, such as dealing with a single NGINX container in a single machine, or deploying multiple sites with a single PHP-FPM container, all of which are unsuccessful.

After reflection and summary, two methods have been successfully implemented at present:

Single Nginx, multiple PHP-FPM, single Nginx, single PHP-FPM

Single Nginx, multiple 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 profile:

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;}}

Single Nginx, single 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-networknetworks: leoedu-network: driver: bridge

The key points of NGINX configuration are:

Astcgi_param SCRIPT_FILENAME / var/www/html/nick.com/$fastcgi_script_name

For the specific reason, I'll make it up later when I'm free. This article is just a record.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report