【Docker】宝塔创建Docker容器配置nginx

打印 上一主题 下一主题

主题 550|帖子 550|积分 1650

媒介

本篇是我入门docker的第一篇,由于docker具有很好的移植性,易于安装,开箱即用;签约的公司项目开发需要我举行学习,否则money减半,5555~
百度找了一圈,只有关于docker怎么装宝塔服务器的却没有一篇宝塔中的docker装情况的,没办法只能自己探索了,有人会问为什么不使用Windows上的docker,我的电脑是win11,尝试装了装不上,于是使用服务器上的docker
创建容器

点击【创建容器】

拉取【nginx1.18】
容器命名为【test】
端口映射【3000->80】
   1、拉取nginx是由于部署的项目时web情况,不清楚自己了解,除了nginx常用的还有apache
2、端口为什么需要映射,我的服务器已经占用了80端口,我通过防火墙规则开放一个端口例如:3000 访问它时让它指向docker容器的80端口
  

启动


   这张图是我盗过来的,访问你的ip:3000打开如图说明docker部署nginx情况乐成
  部署h5项目

将项目移动至www/wwwroot里(留意:这里的目次是docker的目次,不是宝塔的,不知道docker目次可通过对容器操作跳转到目次路径)

修改nginx配置
路径:/var/lib/docker/*********/etc/nginx/conf.d

  1. server {
  2.     listen       80;
  3.     listen  [::]:80;
  4.     server_name  localhost;
  5.     #charset koi8-r;
  6.     #access_log  /var/log/nginx/host.access.log  main;
  7.     location / {
  8.         root   /www/wwwroot/*******;
  9.         index  index.html index.htm;
  10.     }
  11.     #error_page  404              /404.html;
  12.     # redirect server error pages to the static page /50x.html
  13.     #
  14.     error_page   500 502 503 504  /50x.html;
  15.     location = /50x.html {
  16.         root   /www/wwwroot/*********;
  17.     }
  18.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  19.     #
  20.     #location ~ \.php$ {
  21.     #    proxy_pass   http://127.0.0.1;
  22.     #}
  23.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  24.     #
  25.     #location ~ \.php$ {
  26.     #    root           html;
  27.     #    fastcgi_pass   127.0.0.1:9000;
  28.     #    fastcgi_index  index.php;
  29.     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  30.     #    include        fastcgi_params;
  31.     #}
  32.     # deny access to .htaccess files, if Apache's document root
  33.     # concurs with nginx's one
  34.     #
  35.     #location ~ /\.ht {
  36.     #    deny  all;
  37.     #}
  38. }
复制代码
重启访问


末了

本次只是简朴的先容了docker怎样拉取nginx部署h5项目,假如需要毗连mysql、以及php等其他情况,后面再继续增补

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

飞不高

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表