生活随笔
收集整理的這篇文章主要介紹了
使用Docker搭建WordPress博客(三)nginx镜像制作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.查看創(chuàng)建nginx鏡像所有文件
[root@localhost nginx]# ls
default.conf Dockerfile fastcgi_params run.sh
2.創(chuàng)建Dockerfile文件
[root@localhost nginx]# cat Dockerfile
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.創(chuàng)建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.創(chuàng)建fastcgi_params
[root@localhost nginx]
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.創(chuàng)建run.sh
[root@localhost nginx]# cat run.sh
#!/bin/sh
/usr/sbin/php-fpm -D
/usr/sbin/nginx -g
"daemon off;" 6.創(chuàng)建nginx鏡像
docker build -f Dockerfile -t weibo_nginx:v1 .
說明:-f 指定文件 , -t 指定生成鏡像名稱 ,冒號后為版本號。
7.查看生成的鏡像
? ? ?本文轉自品鑒初心51CTO博客,原文鏈接:http://blog.51cto.com/wutengfei/2054434,如需轉載請自行聯(lián)系原作者
與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
以上是生活随笔為你收集整理的使用Docker搭建WordPress博客(三)nginx镜像制作的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。