Docker最佳实践-部署LNMP环境
生活随笔
收集整理的這篇文章主要介紹了
Docker最佳实践-部署LNMP环境
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
標簽(linux): docker
筆者Q:972581034 交流群:605799367。有任何疑問可與筆者或加群交流
環境準備
[root@docker ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@docker ~]# free -htotal used free shared buff/cache available Mem: 1.8G 209M 517M 8.9M 1.1G 1.3G Swap: 1.0G 0B 1.0G [root@docker ~]# hostname -I 10.0.0.250 172.16.1.250 systemctl disable firewalld.service systemctl stop firewalld.service iptables -F安裝yum-utils,它提供yum-config-manager實用程序
yum install -y yum-utils添加穩定版本庫
yum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repo更新yum包索引
yum makecache fast安裝Docker社區版
yum install docker-ce -y啟動docker守護進程
systemctl enable docker systemctl start docker systemctl status docker測試,,,網絡延時問題可能會導致測試不成功,多測兩次
docker run hello-world查看鏡像
c7是下面要用來啟動容器的鏡像,在centos鏡像的基礎上安裝了常用軟件包。
[root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE c7 latest 8af948261786 2 days ago 476 MB centos latest a8493f5f50ff 6 weeks ago 192 MB這里需要一些相關的軟件包和配置文件,這里給大家提供了鏈接:http://pan.baidu.com/s/1eR8vdXg 密碼:l1sj
創建web01
docker run --network=host -itd --name=web01 -h web01 c7 docker attach web01使用提供的軟件包安裝nginx
#nginx yum localinstall -y nginx-1.10.2-1.x86_64.rpmnginx配置文件
cd /application/nginx/conf/[root@web01 conf]# cat nginx.conf worker_processes 1; events {worker_connections 1024; } http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65; include extra/blog.conf; } [root@web01 conf]# mkdir extra [root@web01 extra]# ls blog.conf上傳wordpress到站點根目錄
[root@web01 extra]# cd /application/nginx/html/ [root@web01 html]# wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz [root@web01 html]# tar xf wordpress-4.7.4-zh_CN.tar.gz [root@web01 html]# chown -R www.www /application/nginx/html啟動nginx,安裝php并啟動
/application/nginx/sbin/nginx chmod +x /etc/rc.local echo "/application/nginx/sbin/nginx" >> /etc/rc.local#php yum localinstall libiconv-devel-1.15-1.x86_64.rpm php-5.5.32-1.x86_64.rpm -y /application/php/sbin/php-fpm chmod +x /etc/rc.local echo "/application/php/sbin/php-fpm" >> /etc/rc.local創建數據庫容器
docker run --network=host -itd --name=db01 -h db01 c7 docker attach db01安裝并啟動數據庫
yum -y install mariadb mariadb-servermysql_install_db --user=mysqlmysqld_safe &>/dev/null & /usr/bin/mysqladmin -u root password '123456' mysql -uroot -p123456創建wordpress庫和授權帳戶
create database wordpress; grant all on wordpress.* to 'wordpress'@'localhost' identified by '123456'; grant all on wordpress.* to wordpress@'172.16.1.250' identified by '123456';登錄瀏覽器測試
來個美女養養眼
docker常用命令
http://www.cnblogs.com/Csir/p/6888474.html
轉載于:https://www.cnblogs.com/Csir/p/6888066.html
總結
以上是生活随笔為你收集整理的Docker最佳实践-部署LNMP环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: J20170521-ts
- 下一篇: django-admin.py 不是内部