一、编写dockerfile
[root@docker01 wordpress] FROM centos:7 RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo RUN yum install nginx mariadb-server php-fpm php-mysql -y RUN mysql_install_db --user=mysql --defaults-file=/etc/my.cnf RUN tmp=`nohup mysqld_safe --defaults-file=/etc/my.cnf &` && sleep 5 && \ mysql -e "create database wordpress;" && \ mysql -e "grant all on wordpress.* to wordpress@localhost identified by '123456';" ADD www.conf /etc/php-fpm.d/www.conf ADD nginx.conf /etc/nginx/nginx.conf RUN mkdir /code WORKDIR /code ADD wordpress-4.9.4.zip . RUN yum install unzip -y RUN unzip wordpress-4.9.4.zip RUN mv wordpress/* . RUN chown -R nginx:nginx . ADD init.sh /init.sh CMD ["/bin/bash","/init.sh"]
二、准备nginx配置文件
server { listen 80; server_name localhost; root /code; location / { index index.php index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
三、修改/etc/php-fpm.d/www.conf
[root@docker01 wordpress] user = nginx group = nginx
四、准备wordpress软件包,5以上版本不支持
[root@docker01 wordpress] -rw------- 1 root root 9332728 May 29 20:50 wordpress-4.9.4.zip
五、编写初始化脚本,数据库后台启动
[root@docker01 wordpress] nginx php-fpm -D mysqld_safe --defaults-file=/etc/my.cnf
六、运行dockerfile
[root@docker01 wordpress]
七、启动容器
[root@docker01 wordpress] 92267d753afa195d268fe67cedafe5203e2b74b0e525c99962577ea6c7a3f758
八、查看网页
原文链接:https://blog.csdn.net/octtom/article/details/106432935?ops_request_misc=&request_id=87ba146a8195450c82f4155ce0d0ac05&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-28-106432935-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
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END