原创

docker安装nginx,phpfpm以及php56安装mysqli扩展

1.docker-compose.yml文件

version: '3'
services:
    php: 
        build: .
        ports:
          - "9000:9000"
        restart: always
        privileged: "true"
        volumes:
            - "$PWD/nginx/html:/var/www/html"
        networks:
            lsh:
                aliases:
                    - php56
    nginx:
        image: nginx:1.17.8
        depends_on:
            - "php"
        volumes:
            - "$PWD/nginx/conf.d:/etc/nginx/conf.d"
            - "$PWD/nginx/html:/var/www/html"
        privileged: "true"
        ports:
            - "8011:80"
        restart: always
        networks: 
            - lsh
networks:
    lsh:
        external: true

2.Dockerfile docker php安装mysqli扩展

FROM php:7.2-fpm

RUN apt-get update 
RUN apt-get install -y iputils-ping
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

3.nginx.conf 放在$PWD/nginx/conf.d下

# #user  nobody;
# worker_processes  1;

# #error_log  logs/error.log;
# #error_log  logs/error.log  notice;
# #error_log  logs/error.log  info;

# #pid        logs/nginx.pid;
# events {
#     worker_connections  1024;
# }

server {
    listen       80;
    server_name  localhost;
    location / {
        root   /var/www/html;
        index  index.html index.htm index.php;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }
    location ~ .*\.(php)$ {
        fastcgi_pass   php56:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
             include        fastcgi_params;
              index  index.html index.htm;
         #include  fastcgi.conf;
    }
}
正文到此结束
本文目录