docker创建nginx+php-fpm+mysql环境(一分钟搭建lnmp)
下载镜像
docker pull bitnami/php-fpm #下载php-fpm镜像
docker pull nginx #下载nginx镜像
docker pull mysql:5.5.59 #下载mysql镜像
创建volume\network
docker volume create webpage #用于容器web页面存放,存储位置默认为:/var/lib/docker/volume/webpage/_data/
docker network create --subnet=172.30.0.0/24 lnmp #创建网络,方便配置文件中直接使用容器名称
创建php-fpm、nginx、mysql镜像
docker run -d --name php -v webpage:/var/www --net lnmp --restart=always bitnami/php-fpm
docker run -d --name nginx -p 80:80 -v webpage:/var/www --net lnmp --restart=always nginx
docker run -itd --name mysql --restart=always -p3306:3306 -e MYSQL_ROOT_PASSWORD=123456 --net lnmp mysql:5.5.59
修改docker下default.conf文件,文件目录/etc/nginx/conf.d/default.conf ,内容如下:
server {
listen ;
server_name localhost;
location / {
root /var/www;
index index.html index.htm index.php;
}
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /var/www;
fastcgi_pass php:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
若不方便修改,可以使用docker cp命令,在宿主机上写好再复制到容器中替换,复制命令如下:
docker cp default.conf nginx:/etc/nginx/conf.d/default.conf
重启nginx容器
docker restart nginx
创建测试文件
<?php phpinfo.php ?>
将文件移动到数据卷目录下(web根目录就在这个目录下)
mv index.php /var/lib/docker/volume/webpage/_data/
docker创建nginx+php-fpm+mysql环境(一分钟搭建lnmp)的更多相关文章
- docker创建nginx镜像
注意:此处不是用的dockerfile创建的镜像,只是用来搞一搞 首先你的系统里面要安装docker,这里就不重复介绍了,可以看之前的文章: 然后再搞一个基础镜像 docker pull regist ...
- Linux搭建nginx+php/php-fpm+mysql环境
百度内部php框架odp有单独的nginx+php/php-fpm环境,但为了更好的实践,自己搭建一套单独的. 1.首先安装nginx 两种方式: 1)yum源安装(使用root权限)yum inst ...
- 记录一次自己对nginx+fastcgi(fpm)+mysql压力测试结果
nginx + fastcgi(fpm) 压力测试: CentOS release 5.9 16核12G内存 静态页面: 并发1000,压测200秒,测试结果: 系统最大负载5.47 成功响应: 25 ...
- Docker(八)-Docker创建Nginx容器
获取Nginx镜像 最简单的方法就是通过 docker pull nginx 命令来创建 Nginx容器. $ sudo docker pull nginx 或者: $ sudo docker pul ...
- Docker: 创建带数据的MySql container
如果需要想要在一个装有docker的机器上启动一个MySql的container,并且整个MySql container有我想要的数据: 1. 先在已有的MySql instance上准备好数据 2. ...
- Docker创建运行多个mysql容器
1.使用mysql/mysql-server:latest镜像快速启动一个Mysql实例 docker run --name ilink_user_01 -e MYSQL_ROOT_PASSWORD= ...
- windows8 使用docker创建第一个nodejs运行环境
现在公司电脑使用的是windows8操作系统,如果想要运行docker,只能安装Docker ToolBox 关于安装Docker ToolBox,请查看文章<windows8安装docker( ...
- docker下安装centos,并在其上搭建lnmp环境
一.安装CentOs容器 1.进入docker下载CentOs,这里我使用的CentOs6.8 docker pull centos:6.8 2.创建容器 sudo docker run --priv ...
- nginx+apache+php+mysql服务器集群搭建
由于需要搭建了一个基本的服务器集群.具体的配置方案先不说了,到有时间的时候再介绍.下面介绍下整 个方案的优点. 我总共准备了四台阿里云的主机,架设分别是A,B1,B2,C,A在集群的最前面,B1和B2 ...
随机推荐
- [20181130]control file sequential read.txt
[20181130]control file sequential read.txt --//昨天上午探究了大量控制文件读的情况,链接:http://blog.itpub.net/267265/vie ...
- SqlServer通用存储过程
1.增删改—通用存储过程 --增删改 存储过程create proc Infos_InsertUpdateDelete( @Id int, @Name varchar(50), @DataTable_ ...
- Shell按行读取文件的3种方法
Shell按行读取文件的方法有很多,常见的三种方法如下: 要读取的文件: [root@mini05 -]# cat file.info 写法一: [root@mini05 -]# cat read1. ...
- June 11. 2018 Week 24th, Monday
Love is the beauty of the soul. 爱是灵魂之美. From Saint Augustine. The complete version of this quote goe ...
- Unity琐碎(3) UGUI 图文混排解决方案和优化
感觉使用Unity之后总能看到各种各样解决混排的方案,只能说明Unity不够体恤下情啊.这篇文章主要讲一下个人在使用过程中方案选择和优化过程,已做记录.顺便提下,开源很多意味着坑,还是要开实际需求. ...
- Metasploit渗透测试实际应用
Metasploit:如何在 Metasploit 中使用反弹 Shell https://xz.aliyun.com/t/2380 Metasploit:如何使用 msfvenom https:// ...
- Mysql 索引 事物
索引 针对庞大数据 加速查询 缺点 占用空间 分类: 普通索引: 通过 index 创建 唯一索引: 就是 unique key 主键索引: 就是 primary key 联合索引(多列)" ...
- Linux分区的几种方案
通用方法/boot 引导分区 200M swap 交换分区 内存的1.5倍(内存小于8G) 大于8G 给8G/ 根分区 剩下多少给多少 数据非常重要/bootswap/ 50-200G/data 剩下 ...
- dubbo远程方法调用的基本原理
1 dubbo是远程服务调用rpc框架 2 dubbo缺省协议采用单一长连接和NIO通讯 1client端生成一个唯一的id,封装方法调用信息obj(接口名,方法名,参数,处理结果的回调对象),在全局 ...
- JavaScript对象数组根据某属性sort升降序排序
1.自定义一个比较器,其参数为待排序的属性. 2.将带参数的比较器传入sort(). var data = [ {name: "Bruce", age: 23, id: 16 ...