docker安装Nginx并运行vue3前端
- Docker安装Nginx
#获取Nginx
docker pull nginx
#查端口
netstat -ntlp
#建本地目录
mkdir -p /home/nginx/www /home/nginx/logs /home/nginx/conf /home/nginx/conf.d
#创建临时nginx,拷贝conf文件
docker run --rm --name nginx-test -p 80:80 -d nginx
docker ps
docker cp ebe3d49bba69:/etc/nginx/nginx.conf /home/nginx/conf/
docker cp ebe3d49bba69:/etc/nginx/conf.d/default.conf /home/nginx/conf.d/
docker cp ebe3d49bba69:/etc/nginx/mime.types /home/nginx/www
docker stop nginx-test
#Docker Run Nginx
docker run -d -p 80:80 --name nginx-jn -v /home/nginx/www:/usr/share/nginx/html -v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx
- conf.d 下 default.conf 配置
server {
listen 80;
server_name flowable.amadeus.cn;
location / {
root flowhtml;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root flowhtml;
}
}
- 把vue打包的dist文件,上传到本地 /home/nginx/www/下,重命名为flowhtml ,即可。
喜欢请赞赏一下啦^_^