使用Docker搭建WordPress部落格(三)nginx映象製作

技術小胖子發表於2017-11-09

1.檢視建立nginx映象所有檔案

[root@localhost nginx]# ls

default.conf Dockerfile fastcgi_params run.sh

2.建立Dockerfile檔案

[root@localhost nginx]# cat Dockerfile

#VERSION 0.0.1
FROM centos
MAINTAINER wtf  "wtf@data.com"
RUN rpm -ivh http://mirrors.sohu.com/fedora-epel/epel-release-latest-7.noarch.rpm
RUN yum -y install nginx php php-fpm php-cli php-common php-gd php-mbstring php-mcrypt php-mysql php-pdo php-devel php-imagick php-xmlrpc php-xml php-bcmath php-dba php-enchant
ADD default.conf  /etc/nginx/conf.d/default.conf
ADD fastcgi_params  /etc/nginx/fastcgi_params
ADD run.sh  /tmp/
RUN chmod +x /tmp/run.sh
ENTRYPOINT ["./tmp/run.sh"]
EXPOSE 80

3.建立Nginx的default.conf

server {

listen 80 default_server;

servername ;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

error_page  404              /404.html;
location = /404.html {
    root   /usr/share/nginx/html;
}

#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}
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;
}

}

4.建立fastcgi_params

[root@localhost nginx]# cat fastcgi_params
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

5.建立run.sh

[root@localhost nginx]# cat run.sh

#!/bin/sh
/usr/sbin/php-fpm -D
/usr/sbin/nginx -g "daemon off;"

6.建立nginx映象

docker build -f Dockerfile -t weibo_nginx:v1 .

說明:-f 指定檔案 , -t 指定生成映象名稱 ,冒號後為版本號。

7.檢視生成的映象
使用Docker搭建WordPress部落格(三)nginx映象製作

     本文轉自品鑑初心51CTO部落格,原文連結:http://blog.51cto.com/wutengfei/2054434,如需轉載請自行聯絡原作者


相關文章