qidao123.com技术社区-IT企服评测·应用市场
标题:
【Docker】宝塔创建Docker容器配置nginx
[打印本页]
作者:
飞不高
时间:
2024-6-20 21:01
标题:
【Docker】宝塔创建Docker容器配置nginx
媒介
本篇是我入门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
server {
listen 80;
listen [::]:80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /www/wwwroot/*******;
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 /www/wwwroot/*********;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
复制代码
重启访问
末了
本次只是简朴的先容了docker怎样拉取nginx部署h5项目,假如需要毗连mysql、以及php等其他情况,后面再继续增补
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 qidao123.com技术社区-IT企服评测·应用市场 (https://dis.qidao123.com/)
Powered by Discuz! X3.4