docker wordpress php,使用Docker搭建WordPress博客(三)nginx镜像制作

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.查看生成的镜像

9ebf524ed6a7453dfc13521140187579.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值