centos8 docker-compose.yml 部署 Nginx+PHP7 环境

蔚落 2023-07-20 13:37 3阅读 0赞

目录结构

20200329225249656.png

docker-compose.yml

  1. version: "3.3"
  2. services:
  3. nginx:
  4. image: nginx
  5. ports:
  6. - "8080:80"
  7. links:
  8. - php
  9. volumes:
  10. - ./www:/var/www/html
  11. - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
  12. - ./log/nginx:/var/log/nginx
  13. networks:
  14. - webnet
  15. php:
  16. image: php:7.4-fpm
  17. volumes:
  18. - ./www:/var/www/html
  19. expose:
  20. - "9000"
  21. networks:
  22. - webnet
  23. networks:
  24. webnet:

nginx.conf

  1. events {
  2. worker_connections 768;
  3. }
  4. http {
  5. include /etc/nginx/mime.types;
  6. default_type application/octet-stream;
  7. gzip on;
  8. gzip_disable "msie6";
  9. server {
  10. listen 80;
  11. # server_name www.php.com;
  12. root /var/www/html;
  13. access_log /var/log/nginx/access.log;
  14. error_log /var/log/nginx/error.log;
  15. index index.php index.html;
  16. charset utf-8;
  17. location = /favicon.ico { access_log off; log_not_found off; }
  18. sendfile off;
  19. location ~ \.php$ {
  20. try_files $uri =404;
  21. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  22. fastcgi_pass php:9000;
  23. fastcgi_index index.php;
  24. include fastcgi_params;
  25. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  26. fastcgi_intercept_errors off;
  27. fastcgi_buffer_size 16k;
  28. fastcgi_buffers 4 16k;
  29. fastcgi_param HTTPS 1;
  30. }
  31. location ~ /\.ht {
  32. deny all;
  33. }
  34. client_max_body_size 1G;
  35. }
  36. }

index.php

  1. <?php
  2. phpinfo();
  3. ?>

之后启动镜像:

docker-compose up -d

访问网站:http://localhost:8080/

20200329230059464.png

发表评论

表情:
评论列表 (有 0 条评论,3人围观)

还没有评论,来说两句吧...

相关阅读