使用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.查看生成的镜像
使用Docker搭建WordPress博客(三)nginx镜像制作

转载于:https://blog.51cto.com/wutengfei/2054434

原文链接:https://blog.csdn.net/weixin_33920401/article/details/91774985?ops_request_misc=&request_id=fac57cc613c240d997d61d662f2f8fe3&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-17-91774985-null-null.268%5Ev1%5Econtrol&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享