Docker
Docker安装Nginx
本文档使用 MrDoc 发布
-
+
home page
Docker安装Nginx
### 1、创建nginx的文件存储目录 ``` mkdir -p /root/nginx/www /root/nginx/logs /root/nginx/conf ``` www: nginx存储网站网页的目录 logs: nginx日志目录 conf: nginx配置文件目录 ### 2、创建nginx的配置文件 /root/nginx/conf下创建nginx.conf nginx.conf内容如下 ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; 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 120; #gzip on; include /etc/nginx/conf.d/*.conf; server { listen 9001; listen [::]:9001; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } } ``` ### 3、创建新nginx容器 ``` docker run -d -p 9001:9001 --name nginx-web -v /root/nginx/www:/usr/share/nginx/html -v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /root/nginx/logs:/var/log/nginx nginx ```
admin
Nov. 3, 2022, 1:12 p.m.
转发文档
Collection documents
Last
Next
手机扫码
Copy link
手机扫一扫转发分享
Copy link
Markdown文件
share
link
type
password
Update password