docker部署LAMP架构并部署上线wordpress博客系统

第一步:直接在镜像仓库拉取LAMP镜像

[root@ken-node3 ken]# docker pull tutum/lamp

第二步:查看已经获取到的镜像

[root@ken-node3 ken]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tutum/lamp          latest              3d49e175ec00        3 years ago         427MB 

第三步:启动容器

[root@ken-node3 ken]# docker run -p 80:80 -p 3306:3306 -v /ken:/var/www/html -v /ken1:/var/lib/mysql -d tutum/lamp

命令解读:

端口映射本机80端口到容易80端口,确保本机的80端口未被占用

端口映射本机3306端口到容易3306端口,确保本机的3306端口未被占用

目录映射本机的/ken目录到容器的网站根目录,以实现数据持久化及方便管理

目录映射本机的/ken1目录到容器的数据库文件目录,以实现数据持久化及方便管理

后台运行该容器

第四步:准备wordpress安装包到/ken目录下,并进行数据库和用户名的编辑

[root@ken-node3 ken]# ls
wordpress  wordpress-3.3.1-zh_CN.zip
[root@ken-node3 ken]# cp wordpress/* . -a
[root@ken-node3 ken]# ls index.php wordpress-3.3.1-zh_CN.zip wp-blog-header.php wp-cron.php wp-login.php wp-settings.php license.txt wp-activate.php wp-comments-post.php wp-includes wp-mail.php wp-signup.php readme.html wp-admin wp-config-sample.php wp-links-opml.php wp-pass.php wp-trackback.php wordpress wp-app.php wp-content wp-load.php wp-register.php xmlrpc.php [root@ken-node3 ken]# cp wp-config-sample.php wp-config.php [root@ken-node3 ken]# vim wp-config.php 

第五步:进入容易创建相应的数据库及用户

[root@ken-node3 ken]# docker exec -it 9dbad46eb3f2 bash
root@9dbad46eb3f2:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database ken; Query OK, 1 row affected (0.00 sec) mysql> grant all on *.* to ken@'localhost' identified by '123'; Query OK, 0 rows affected (0.00 sec) mysql> grant all on *.* to ken@'%' identified by '123'; Query OK, 0 rows affected (0.01 sec) mysql> exit Bye 

第六步:浏览器进行访问

猜你喜欢

转载自www.cnblogs.com/it-peng/p/11388275.html