【筆記】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 {
        width: 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文件里面,啟動命令的端口再修改一下就完事


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM