翼度科技»论坛 云主机 服务器技术 查看内容

宝塔创建Docker容器配置nginx的实现步骤

4

主题

4

帖子

12

积分

新手上路

Rank: 1

积分
12
前言

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

创建容器

点击【创建容器】

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


启动

  1. 这张图是我盗过来的,访问你的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等其他环境,后面再继续补充
到此这篇关于宝塔创建Docker容器配置nginx的实现步骤的文章就介绍到这了,更多相关宝塔创建Docker配置nginx内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

来源:https://www.jb51.net/server/3222330b7.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

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

x

举报 回复 使用道具