Docker 学习第三课

搭建NGINX + PH-FPM

1、修改NGINX配置文件

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

   #include /etc/nginx/conf.d/*.conf;

   server {
      listen 80;

      location / {
            root /var/www/html;
            index index.php index.html;
      }


      # php解析
      location ~ \.php$ {
            root           /php;
            fastcgi_pass   192.138.0.5:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
      }
   }
}

 

2、启动php-fpm容器

docker run -d --name php-fpm -v /root/php/:/php/ --network nginx-net --ip 192.138.0.6 php:7.2.0-fpm-alpine3.6

3、启动Nginx容器

docker run -d -p 80:80 --rm --name nginx -v /root/php/:/usr/share/nginx/html -v /root/conf/nginx.conf:/etc/nginx/nginx.conf --network nginx-net nginx:1.19.0-alpine

 

posted @ 2020-06-28 15:56  对数螺旋线  阅读(132)  评论(0编辑  收藏  举报