幸运飞艇停吗

ASP源碼.NET源碼PHP源碼JSP源碼JAVA源碼DELPHI源碼PB源碼VC源碼VB源碼Android源碼
當前位置:首頁 >> 網頁制作 >> web前端 >> Docker+Nginx部署網站

Docker+Nginx部署網站

來源:網絡整理     時間:2018-10-20     關鍵詞:

幸运飞艇停吗 BENPIANWENZHANGZHUYAOJIESHAOLE" Docker+NginxBUSHUWANGZHAN",ZHUYAOSHEJIDAOFANGMIANDENEIRONG,DUIYUwebQIANDUANGANXINGQUDETONGXUEKEYICANKAOYIXIA: Docker+NginxBUSHUWANGZHAN YI,DANZHANDIAN 1,DENGLUlinux 2,ANZHUANGdocker wget -qO- http://get.docker.com/ | ...

Docker+Nginx部署網站
一,單站點
1,登錄linux
2,安裝docker
wget -qO- http://get.docker.com/ | sh
3,拉取Nginx鏡像
docker pull nginx
4,在linux里面新建一個目錄www用來試驗
  mkdir www
5,www目錄下面新建html目錄和logs目錄
  mkdir html logs
6,準備靜態網站程序,例如程序放在目錄MyWebSite1里面,再把整個網站程序傳入html目錄下面,例如html/MyWebSite1
7,編輯nginx.conf,例如:
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server {
        listen       8021;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/MyWebSite1;
            index  index.html index.htm;
        }
  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html/MyWebSite1;
        }
    }
}

8,把nginx.conf傳入www目錄, www目錄最終如下

9,創建容器
docker run -p 80:80 --name nginx6 -v $PWD/nginx.conf:/etc/nginx/nginx.conf --privileged=true -v $PWD/html:/etc/nginx/html -v $PWD/logs:/wwwlogs -d nginx
解釋:
-p 80:80 端口映射,多端口映射方法:-p 8081:8081 -p 8082:8082
-v $PWD/nginx.conf:/etc/nginx/nginx.conf  把當前目錄的nginx.conf文件掛載到容器的/etc/nginx/nginx.conf,相當于替換
-v $PWD/html:/etc/nginx/html   掛載html目錄
-v $PWD/logs:/wwwlogs   掛載日志目錄
在瀏覽器輸入http://localhost 驗證網站是否跑起來了,完成。
二,多站點
1,把MyWebSite1,MyWebSite2放入html
2,編輯nginx.conf如下
3,啟動新容器
docker run -p 8021:8021 -p 8022:8022 --name nginx7 -v $PWD/nginx.conf:/etc/nginx/nginx.conf --privileged=true -v $PWD/html:/etc/nginx/html -v $PWD/logs:/wwwlogs -d nginx
在瀏覽器輸入http://localhost:8021,http://localhost:8021 驗證網站是否跑起來了
完成
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server {
        listen       8021;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/MyWebSite1;
            index  index.html index.htm;
        }
  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html/MyWebSite1;
        }
    }
	
server {
        listen       8022;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/MyWebSite2;
            index  index.html index.htm;
        }
  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html/MyWebSite2;
        }
    }
}

幸运飞艇停吗 YISHANGJIUJIESHAOLE Docker+NginxBUSHUWANGZHAN,BAOKUOLEFANGMIANDENEIRONG,XIWANGDUIwebQIANDUANYOUXINGQUDEPENGYOUYOUSUOBANGZHU。

幸运飞艇停吗 BENWENWANGZHILIANJIE:http://snifly.cn/article/detail_4594025.html

幸运飞艇停吗

相關圖片

相關文章