您现在的位置是:首页 > cms教程 > WordPress教程WordPress教程

docker安装wordpress的方法示例

碧凡2025-03-16WordPress教程已有人查阅

导读1、下载centos镜像docker pull centos2、安装mysql数据库FROM centos #原镜像MAINTAINER
RUN yum -y install mariadb-server openssh-server && yum clean all #yum安

1、下载centos镜像
docker pull centos
2、安装mysql数据库
FROM centos #原镜像
MAINTAINER
RUN yum -y install mariadb-server openssh-server && yum clean all #yum安装相应的包
RUN mysql_install_db && chown -R mysql:mysql /var/lib/mysql/ #初始化数据库
VOLUME /var/lib/mysql #定义数据卷
ADD mysql.sh /mysql.sh #添加已经定义好的脚本
RUN chmod 755 /mysql.sh #赋予脚本权限
EXPOSE 22 #暴露22端口
EXPOSE 3306 #暴露3306端口
CMD ["/mysql.sh"] #运行脚本
#!/bin/bash
mysqld_safe &
sleep 5
mysqladmin -uroot password '123456'
mysql -uroot -p123456 -e "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123456';FLUSH PRIVILEGES;"
sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config && ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
echo 123456 | passwd --stdin root
/usr/sbin/sshd -D
执行Dockfile 生成db镜像
docker build -t cc/wordpress:db .
3、生成php镜像
FROM centos
MAINTAINER 547253687@qq.com
RUN yum -y install libxml2 libxml2-devel bzip2 bzip2-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel libcurl libcurl-devel gcc gcc-c++ c++ glibc make autoconf openssl openssl-devel ntpdate crontabs
ADD libmcrypt-2.5.8.tar.gz /usr/local/src
WORKDIR /usr/local/src/libmcrypt-2.5.8/
RUN ./configure && make && make install
ADD php-5.4.44.tar.gz /usr/local/src
WORKDIR /usr/local/src/php-5.4.44/
RUN ./configure --prefix=/usr/local/php --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-mcrypt --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/usr/local/php/etc --with-bz2 --with-gd && make && make install
COPY php.ini-production /usr/local/php/etc/php.ini
COPY php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
RUN useradd -M -s /sbin/nologin php
RUN sed -i -e 's@;pid = run/php-fpm.pid@pid = run/php-fpm.pid@g' -e 's@nobody@php@g' -e 's@listen = 127.0.0.1:9000@listen = 0.0.0.0:9000@g' /usr/local/php/etc/php-fpm.conf
RUN sed -i 's@;daemonize = yes@daemonize = no@g' /usr/local/php/etc/php-fpm.conf
EXPOSE 9000
CMD ["/usr/local/php/sbin/php-fpm"]
生成php镜像
docker build -t cc/wordpress:php .
4、生成nginx镜像
FROM centos
MAINTAINER 547253687@qq.com
RUN groupadd
RUN useradd -g
ADD nginx-1.15.2.tar.gz /usr/local/src
RUN yum install libxslt-devel -y gd gd-devel GeoIP GeoIP-devel pcre pcre-devel gcc gcc-c++ c++ glibc make autoconf openssl openssl-devel ntpdate crontabs
WORKDIR /usr/local/src/nginx-1.15.2
RUN ./configure --user=--group=--prefix=/usr/local/nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-
http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradatio
n_module --with-http_stub_status_module && make && make install
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
COPY fastcgi_params /usr/local/nginx/conf/fastcgi_params
RUN mkdir -p /data/proxy_cache_path/
RUN mkdir -p /usr/local/nginx/ssl/
RUN mkdir -p /usr/local/nginx/conf.d/
RUN mkdir -p /usr/local/nginx/log/
COPY ssl/cert.key /usr/local/nginx/ssl/
COPY ssl/cert.pem /usr/local/nginx/ssl/
COPY wordpress.conf /usr/local/nginx/conf.d/
EXPOSE 80
CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
nginx.conf配置文件
user;
worker_processes 1;
error_log /usr/local/nginx/log/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/log/access.log main;
sendfile on;
#tcp_nopush on;
#gzip on;
client_header_timeout 10;
client_body_timeout 10;
reset_timedout_connection on;
keepalive_timeout 60 50;
client_header_buffer_size 4k;
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}
geo $whiteiplist {
default 1;
192.168.29.7 0;
192.168.32.230 0;
113.91.190.11 0;
121.34.53.218 0;
}
map $whiteiplist $limit {
# 1 $binary_remote_addr;
1 $clientRealIp;
0 "";
}
limit_req_zone $limit zone=one:10m rate=6r/m;
limit_conn_zone $limit zone=conn_zone:10m;
# limit_req_status 503;
# limit_req_zone $limit zone=one:10m rate=6r/m;
# limit_req_conn
proxy_cache_path /data/proxy_cache_path levels=1:2 keys_zone=cache_zone:100m max_size=1g inactive=60m use_temp_path=off;
proxy_temp_path /data/proxy_temp_path;
# limit_req zone=one burst=3 nodelay;
server_tokens off;
proxy_connect_timeout 100;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
client_max_body_size 30m;
client_body_buffer_size 512k;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding "";
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-IP $http_x_real_ip;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $http_x_forwared_for;
include /usr/local/nginx/conf.d/*.conf;
}
wordpress.conf配置文件
server {
listen 443 ssl;
server_name.jcici.com;
root /wordpress;
index index.php index.html index.htm;
ssl on;
ssl_certificate /usr/local/nginx/ssl/cert.pem;
ssl_certificate_key /usr/local/nginx/ssl/cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
access_log /usr/local/nginx/log/cc.access.log;
error_log /usr/local/nginx/log/cc.error.log;
location ~ \.php$ {
root /wordpress;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
fastcgi_pass php:9000; 这里的php又link来指定
生成nginx镜像
docker build -t cc/wordpress:nginx .
5、运行镜像
启动db docker run -d -p 20002:22 --name db cc/wordpress:db 可以用ssh 20002来管理db这个容器
docker run -d --name=php -v /webapp:/wordpress cc/wordpress:php
docker run -d -p 443:443 --name nginx --link=php:php -v /webapp:/wordpress cc/wordpress:nginx

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)教育培训机构集团网站pbootcms源码下载本模板基于PbootCMS系统开发,为教育培训机构设计,特别适合展示课程体系、师资团队和教学成果。采用响应式技术,确保在各类设备上都能提供良好的浏览体验。查看源码
  • (响应式)蓝色智能摄像头安防防盗电子设备免费pbootcms源码下载这是一款针对智能安防行业特点设计的网站模板,采用蓝色系配色方案,体现科技感和安全性。模板包含产品展示、解决方案、技术支持和新闻中心等核心模块,能够全面展示智能安防设备的技术特点和行业应用。查看源码
  • (PC+WAP)蓝色电子半导体电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为半导体和电子科技行业设计,特别适合电子元器件、集成电路、半导体设备及相关技术产品展示。查看源码
  • (自适应)蓝色建材亚克力板材装饰材料pbootcms网站模板这款基于PbootCMS开发的响应式模板为建材板材行业优化设计,适用于亚克力板材、建筑装饰材料等企业展示需求。采用HTML5技术实现手机/PC跨终端适配,管理员通过统一后台即可同步查看源码
  • pbootcms响应式蓝色旅游旅行社pbootcms网站源码下载为旅游公司、旅行社定制的响应式网站模板,聚焦旅游线路展示、景点推荐及预约服务场景。采用PbootCMS内核开发,自适应技术确保PC与手机端数据实时同步查看源码
  • (自适应)蓝色五金制品配件管件pbootcms网站源码下载基于PbootCMS内核开发的五金行业专用模板,采用响应式设计架构,确保产品展示在各类移动设备上的呈现。通过模块化布局与工业风视觉设计,帮助五金企业高效展示产品规格、应用场景及技术支持,建立专业可靠的行业形象。查看源码
分享笔记 (共有 篇笔记)
验证码: