docker:構建nginx+php-fpm鏡像(一):構建nginx自啟動鏡像,nginxphp-fpm

來源:互聯網
上載者:User

docker:構建nginx+php-fpm鏡像(一):構建nginx自啟動鏡像,nginxphp-fpm
步驟一:手動安裝nginx環境,並記錄全過程:#使用yum更新系統yum -y update #下面編譯安裝tengine,查看有哪些包需要安裝#安裝wget包,用於擷取安裝軟體包yum -y install wget cd /usr/local/src#下載nginx安裝包,並指定放置目錄/usr/local/srcwget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz -P /usr/local/src/#z匹配.gz  x解壓 f本地tar -zxf tengine-2.1.2.tar.gz #建立nginx需要的使用者和組groupadd -r nginxuseradd -g nginx -M nginx #tengine初次編譯./configure --prefix=/usr/local/tengine \--user=nginx --group=nginx #報錯以及補充系統包:yum -y install gcc pcre-devel openssl-devel #初次編譯通過,增加nginx模組配置再次編譯:--with-http_realip_module  #nginx擷取用戶端真實IP的模組--with-http_sub_module  #用於替換網站頁面關鍵字--平常基本沒啥用--with-http_gzip_static_module  #靜態緩衝壓縮,用於減少流量--with-http_gunzip_module  #為不支援gzip模組的用戶端提供解壓縮服務,用於節省空間的減少IO--with-http_ssl_module  #使nginx支援https--with-pcre  #nginx支援pcre正則,主要是支援rewrite功能--with-http_stub_status_module #用於監控nginx狀態 完整編譯命令如下: 

./configure --prefix=/usr/local/tengine \--user=nginx --group=nginx \--with-http_realip_module \--with-http_gzip_static_module \--with-http_gunzip_module \--with-pcre \--with-http_stub_status_module \--with-http_ssl_module
#編譯安裝make & make install #啟動nginx/usr/local/tengine/sbin/nginx 步驟二:根據以上步驟構建dockerfile產生nginx鏡像Dockerfile 
####################################################Dockerfile to build mysqlDB container images#base on centos####################################################Set the base image to Centos6FROM centos:6#File SuthorMAINTAINER liujian@wanbu.com.cn #install basic rpmRUN yum -y updateRUN yum -y install wget gcc pcre-devel openssl-develRUN wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz -P /usr/local/src/ \&& groupadd -r nginx && useradd -g nginx -M nginxRUN cd /usr/local/src/ \&& tar -zxf tengine-2.1.2.tar.gz \&& cd tengine-2.1.2/ \&& ./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_realip_module --with-http_gzip_static_module --with-http_gunzip_module --with-pcre --with-http_stub_status_module --with-http_ssl_module \&& make && make install \&& ln -s /usr/local/tengine/sbin/nginx /usr/sbin/nginx \&& yum -y remove wget gcc pcre-devel openssl-develADD nginx.conf /usr/local/tengine/conf/EXPOSE 80CMD ["nginx","-g","deamon off;"]

 

 #制定Dokcerfile構建nginx鏡像docker build -t nginx_test:v1.0 . #使用鏡像建立容器,測試nginx運行情況docker run -itd -p 0.0.0.0:7788:80 --name nginx_image_test nginx_test:v1.0 #訪問正常,但是nginx設定檔無法修改,只能啟動運行。如果在測試環境需要修改設定檔重啟等,可以使用:#將dockerfile內部CMD ["nginx","-g","deamon off;"]替換為ENTRYPOINT /usr/sbin/nginx -c /etc/nginx/nginx.conf && /bin/bash

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.