第二十一章 Centos7下Docker安装Nginx
2021/12/25 7:10:39
本文主要是介绍第二十一章 Centos7下Docker安装Nginx,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、查找Nginx镜像
[root@staging ~]# docker search nginx
二、拉取Nginx镜像
[root@staging ~]# docker pull nginx
三、运行Nginx
[root@staging ~]# docker run \ -itd \ -p 8080:80 \ -v /data2/nginx/html:/usr/share/nginx/html \ -v /data2/nginx/logs:/var/log/nginx \ -v /data2/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime \ --restart always \ --privileged=true \ --name nginx \ nginx
四、编写Nginx配置文件
[root@staging ~]# vim nginx.conf user root; worker_processes auto; worker_cpu_affinity auto; error_log /var/log/nginx/error.log warn; pid /run/nginx.pid; worker_rlimit_nofile 35535; events { use epoll; worker_connections 10240; } http { include mime.types; default_type application/octet-stream; charset utf-8; 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; server_tokens off; client_max_body_size 200m; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; gzip on; gzip_disable "MSIE [1-6]\."; gzip_http_version 1.1; gzip_comp_level 2; gzip_buffers 16 8k; gzip_min_length 1024; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/jpeg; include /etc/nginx/conf.d/*.conf; }
五、编写Nginx的html文件
[root@staging ~]# cd /data2/nginx/html/ [root@staging test]# echo "wo shi dashuaige" > test.html
六、测试访问
这篇关于第二十一章 Centos7下Docker安装Nginx的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-29100 个常见的 Docker 错误及解决方案
- 2024-09-26制作 llama3 RAG 系统的 Docker 容器
- 2024-09-25Podman — 一个简单、轻量的 Docker 替代品
- 2024-09-25Docker 快速参考指南(初学者版) ??
- 2024-09-25使用 Docker 在单个 VPS 上部署多个应用
- 2024-09-21Docker环境部署资料:新手入门指南
- 2024-09-20Docker环境部署项目实战:新手入门全攻略
- 2024-09-20Docker环境部署:新手入门教程
- 2024-09-20Docker环境部署学习:从入门到实践
- 2024-09-20Docker环境部署入门:新手必读指南