• 【笔记】Docker部署Nginx,并修改配置文件


    先来一个删除命令:)

    root@fudonghai:~# rm -rf /usr/docker/nginx/{conf.d,html,log}
    root@fudonghai:~# rm -r /usr/docker/

    宿主机建这几个目录,用于共享

    root@fudonghai:~# mkdir -p /usr/docker/nginx/{conf.d,html,log}
    root@fudonghai:~# ls /usr/docker/nginx/
    conf.d  html  log

    在宿主机的conf.d文件夹里面放入odoo.conf,样例如下

    server{
        listen 80;
        server_name your_server_name;   #你的serverName
        root /usr/share/nginx/html;
        index index.html;
     }

    在html文件夹里面放入index.html(静态网页用于测试)

    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>

    容器启动命令

    docker run 
    --name my_nginx 
    -d -p 30002:80 
    -v /usr/docker/nginx/log:/var/log/nginx  
    -v /usr/docker/nginx/html:/usr/share/nginx/html 
    -v /usr/docker/nginx/conf.d:/etc/nginx/conf.d  
    nginx:1.16.0

    浏览器访问ip:30002

    这样就把nginx彻底做成一个无状态的容器,具体配置在宿主机的conf文件里面,启动命令的端口再修改一下就完事

  • 相关阅读:
    django email用法
    django ImageField用法
    django集成微博内容
    python读写zip文件
    读写文件
    404渲染
    bzoj1297 / P4159 [SCOI2009]迷路
    bzoj1009 / P3193 [HNOI2008]GT考试
    poj2115 C Looooops(exgcd)
    bzoj1407 / P2421 [NOI2002]荒岛野人(exgcd)
  • 原文地址:https://www.cnblogs.com/fudonghai/p/11316118.html
Copyright © 2020-2023  润新知