寶塔創(chuàng)建Docker容器配置nginx的實現步驟
前言
本篇是我入門docker的第一篇,由于docker具有很好的移植性,易于安裝,開箱即用;簽約的公司項目開發(fā)需要我進行學習,否則money減半,5555~
百度找了一圈,只有關于docker怎么裝寶塔服務器的卻沒有一篇寶塔中的docker裝環(huán)境的,沒辦法只能自己探索了,有人會問為什么不使用Windows上的docker,我的電腦是win11,嘗試裝了裝不上,于是使用服務器上的docker
創(chuàng)建容器
點擊【創(chuàng)建容器】

拉取【nginx1.18】
容器命名為【test】
端口映射【3000->80】
1、拉取nginx是因為部署的項目時web環(huán)境,不清楚自己了解,除了nginx常用的還有apache
2、端口為什么需要映射,我的服務器已經占用了80端口,我通過防火墻規(guī)則開放一個端口例如:3000 訪問它時讓它指向docker容器的80端口

啟動

這張圖是我盜過來的,訪問你的ip:3000打開如圖說明docker部署nginx環(huán)境成功
部署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等其他環(huán)境,后面再繼續(xù)補充
到此這篇關于寶塔創(chuàng)建Docker容器配置nginx的實現步驟的文章就介紹到這了,更多相關寶塔創(chuàng)建Docker配置nginx內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
skywalking agent 關聯docker鏡像的多種方法
Apache SkyWalking 提供了多種方式來部署和使用 SkyWalking Agent,包括在 Docker 容器中運行的應用,本文給大家分享幾種方式將 SkyWalking Agent 集成到你的 Docker 應用中,感興趣的朋友一起看看吧2025-04-04

