{"id":153,"date":"2020-10-29T20:09:09","date_gmt":"2020-10-29T12:09:09","guid":{"rendered":"https:\/\/www.92k.xin\/?p=153"},"modified":"2020-11-10T10:37:36","modified_gmt":"2020-11-10T02:37:36","slug":"docker%e4%b8%8b%e6%9e%84%e5%bb%banginx%e9%95%9c%e5%83%8f","status":"publish","type":"post","link":"https:\/\/www.92k.xin\/?p=153","title":{"rendered":"docker\u4e0b\u6784\u5efaNginx\u955c\u50cf"},"content":{"rendered":"\n

\u6700\u8fd1\u6298\u817enginx\u6709\u70b9\u591a\uff0c\u5927\u5bb6\u5fcd\u5fcd\uff0c\u4eca\u5929\u6211\u4eec\u8981\u8bb2\u7684\u662fdocker\u4e0b\u6784\u5efaNginx\u4e3a\u4f8b\uff0c\u6765\u8bb2\u89e3docker\u4e0b\u955c\u50cf\u7684\u5236\u4f5c\u3002Nginx\u7684\u7f16\u8bd1\u53c2\u6570\u53c2\u8003 Nginx 1.18.0 \u5b89\u88c5\u811a\u672c<\/a><\/p>\n\n\n\n

\u6211\u4eecdocker\u7528\u7684\u57fa\u7840\u955c\u50cf\u7528CENTOS\uff1a docker pull centos \u83b7\u5f97\u3002<\/p>\n\n\n\n

\u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55 \uff0c\u7136\u540e\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6 Dockerfile\uff0c\u5185\u5bb9\u5982\u4e0b<\/p>\n\n\n\n

# Version: 0.0.1\nFROM centos:7\nMAINTAINER 92k \"admin@92k.xin\"\nRUN yum -y update\nRUN yum -y install gcc gcc-c++ wget make file openssl openssl-devel \nWORKDIR \/web\/soft\/\nRUN wget http:\/\/nginx.org\/download\/nginx-1.18.0.tar.gz -P \/web\/soft\/\nRUN wget https:\/\/ftp.pcre.org\/pub\/pcre\/pcre-8.44.tar.gz -P \/web\/soft\/\nRUN wget http:\/\/www.zlib.net\/zlib-1.2.11.tar.gz -P \/web\/soft\/\nRUN tar -zxf nginx-1.18.0.tar.gz\nRUN tar -zxf pcre-8.44.tar.gz\nRUN tar -zxf zlib-1.2.11.tar.gz\nRUN cd nginx-1.18.0 &&.\/configure --prefix=\/web\/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-pcre=..\/pcre-8.44\/ --with-zlib=..\/zlib-1.2.11\/ && make&& make install\nEXPOSE 80\/tcp 443\/tcp\nCMD [\"\/web\/nginx\/sbin\/nginx\"]\nRUN echo \"daemon off;\" >> \/web\/nginx\/conf\/nginx.conf\nRUN rm -rf \/web\/nginx\/conf\/*.default<\/pre><\/div>\n\n\n\n

\u8fd9\u4e2a\u7f16\u8bd1\u8fc7\u7a0b\u5c11\u4e86 openssl\u90e8\u5206\uff0c\u66ff\u4ee3\u7684\u662f\u7cfb\u7edf\u7684openssl\uff0c\u7528\u539f\u6765\u7684\u90a3\u4e2a\uff0c\u4e00\u76f4\u4f1a\u7f16\u8bd1\u4e0d\u8fc7\uff0c\u4e0d\u77e5\u9053\u4e3a\u5565\uff0c\u5c31\u662fopenssl\u8fd9\u91cc\u7f16\u8bd1\u4e0d\u8fc7\u53bb\u3002<\/span><\/strong><\/p>\n\n\n\n

\u4e0a\u8ff0\u95ee\u9898\u627e\u4e86\u4e86\uff0c\u5c11\u4e86\u4e00\u4e2a perl(2020\u5e7411\u670810\u65e5)<\/p>\n\n\n\n

docker build -t nginx:v0.0.1<\/p>\n\n\n\n

\u7f16\u8bd1\u5b8c\u6210\u540e \u6211\u4eec\u53ef\u4ee5\u901a\u8fc7docker images \u770b\u5230\u6211\u4eec\u7684nginx\u7684\u955c\u50cf\u4e86\u3002<\/p>\n\n\n\n

\u6211\u4eec\u5148\u8dd1\u8d77\u6765\uff1a<\/p>\n\n\n\n

docker run –name Nginx -p 80:80 -p443:443 -d nginx:v0.0.1<\/p>\n\n\n\n

\u606d\u559c\u81ea\u5df1\u6210\u529f\u7f16\u8bd1\u597d\u4e86Nginx \u5e76\u987a\u5229\u5de5\u4f5c\u3002<\/p>\n\n\n\n

\u6709\u70b9\u9057\u61be\uff0c\u6211\u4eec\u7684Nginx\u5927\u5c0f524MB\uff0c\u6709\u70b9\u5927\uff0c\u6211\u4eec\u9700\u8981\u7626\u8eab\uff0c\u8fd1\u671f\u5199\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6700\u8fd1\u6298\u817enginx\u6709\u70b9\u591a\uff0c\u5927\u5bb6\u5fcd\u5fcd\uff0c\u4eca\u5929\u6211\u4eec\u8981\u8bb2\u7684\u662fdocker\u4e0b\u6784\u5efaNginx\u4e3a\u4f8b\uff0c\u6765\u8bb2\u89e3docker\u4e0b\u955c\u50cf… <\/p>\n