*★如果文章对你有帮助【关注点赞❤️收藏⭐】一起努力!★*
六 个人主页:花棉袄
本章内容:【Docker部署:Nginx】
✍ 版权: 本文由【花棉袄】原创在CSDN首发需要转载请联系博主
柳部署Nginx
1️⃣本地创建挂载文件夹
mkdir -p /nginx/{log,conf,html,conf.d}
本章内容:【Docker部署:Nginx】
✍ 版权: 本文由【花棉袄】原创在CSDN首发需要转载请联系博主
在log文件夹下创建
touch /mydata/nginx/log/{access.log,error.log}
2️⃣创建nginx.conf
在/mydata/nginx/conf/nginx.conf
user nginx;
worker_processes 1;
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;
}
3️⃣创建default.conf
在/mydata/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
4️⃣创建index.html
/mydata/nginx/html/index.html
5️⃣创建nginx容器Welcome to nginx! hello docker!
docker run --name nginx -d -p 80:80 -v /mydata/nginx/log:/var/log/nginx -v /mydata/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /mydata/nginx/conf.d:/etc/nginx/conf.d -v /mydata/nginx/html:/usr/share/nginx/html nginx
访问:http://localhost:80/index.html
*★如果文章对你有帮助【关注点赞❤️收藏⭐】一起努力!★*
全栈小狐狸的逆袭之路: Java学习路线 Docker部署:Nginx Docker部署:Nacos



