zoukankan      html  css  js  c++  java
  • 最小 docker_lpnm系统

    docker_lpnm

    最小的 nginx-php-mysql 系统

    使用docker-compose 构建一个nginx-php-mysql系统,可以通过浏览器访问以下页面:

      localhost/index

      localhost/text.php

      localhost/mysql.php

    目录结构

    -docker_lpnm

      -conf

        -nginx.conf

      -html

        -index.html

        -mysql.php

        -test.php

      -docker-compose.yml

    nginx.conf中

    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    http {                                                  
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
    
        keepalive_timeout  65;
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                root   /usr/share/nginx/html;
                index  index.html index.htm;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
    
            location ~ .php$ {                     
                fastcgi_pass    php:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME     /var/www/html/$fastcgi_script_name;    
                include         fastcgi_params;
            }
        }
    }

    index.html中

    index.html

    mysql.php中

    <?php
    $servername = 'mysql';
    $username = 'root';
    $password = '123456';
    $conn = mysqli_connect($servername,$username,$password);
    if(! $conn)
    {
        die('could not connect:'.mysqli_error());
    }
        echo 'mysql connected!!!';
        mysqli_close($conn)
    ?>

    test.php中

    <?php
    phpinfo();
    ?>

    docker-compose.yml

    version: "3"
    services:
      nginx:
        image: nginx:alpine
        ports:
        - 80:80
        volumes:
        - ./html:/usr/share/nginx/html
        - ./conf/nginx.conf:/etc/nginx/nginx.conf
      php:
        image: devilbox/php-fpm:8.0-work-0.106
        volumes:
        - ./html:/var/www/html
      mysql:
        image: mysql:5.6
        environment:
        - MYSQL_ROOT_PASSWORD=123456
  • 相关阅读:
    JAVA 网格布局管理器
    JAVA 流式布局管理器
    JAVA 边界布局管理器
    JAVA 图形界面 JFrame容器
    MySQL联合查询语法内联、左联、右联、全联
    ASP.NET MVC URL重写与优化(进阶篇)-继承RouteBase玩转URL
    ASP.NET MVC URL重写与优化(初级篇)-使用Global路由表定制URL
    MVC过滤器详解
    Dapper的基本使用
    JQuery fullcalender文档
  • 原文地址:https://www.cnblogs.com/shiyishou/p/14014872.html
Copyright © 2011-2022 走看看