mac docker安装lnmp环境

一、docker安装
https://www.docker.com/docker-mac
一路傻瓜安装即可
二、doecker使用
1.安装ubuntu
docker pull ubuntu
2.进入ubuntu
docker run -i -t REPOSITORY:TAG /bin/bash
3.更新
apt-get update
4.安装常用工具
apt-get install -y curl vim
5.解决可能存在的语言问题
apt-get install -y language-pack-en-base
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
三、安装环境
1.安装nginx
apt-get install -y nginx
1)配置文件位置
/etc/nginx/nginx.conf
/etc/nginx/conf.d/*.conf
2)主目录
/usr/share/nginx/html/
3)管理nginx服务
service nginx start // 启动
service nginx stop // 停止
service nginx restart // 重启
2.安装php
1)apt-get install -y software-properties-common
2)apt-get install -y php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-xml php7.0-mcrypt php7.0-json php7.0-gd php7.0-mbstring php7.0-zip php-mongodb php-memcached php-redis
3)php -v查看版本
4)配置php.ini
vim /etc/php/7.0/fpm/php.ini
将cgi.fix_pathinfo=1这一行去掉注释,将1改为0
5)配置php-fpm
vim /etc/php/7.0/fpm/pool.d/www.conf
6)修改
listen = /var/run/php/php7.0-fpm.sock
7)配置nginx
vim /etc/nginx/sites-enabled/default
8)将index index.html index.htm;改成index index.php index.html index.htm;
service里面,location /{}下面增加以下配置
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
3.运行
启动php-fpm/nginx
service php7.0-fpm start
service nginx reload
curl localhost
4.安装mysql
apt-get install -y mysql-server-5.6
service mysql start
5.设置容器开机启动项
vim ~/.bashrc
开机启动项
service php7.0-fpm start
service mysql start
service nginx start
四、将配置好的Docker容器,打包
1.将容器打包成镜像
1)exit;退出docker,查看ID docker ps -a
2)将容器打包新的镜像 (ID: 2c10b080cf8c)
docker commit 2c10b080cf8c kfk-lnmp
3)查看新的镜像/Pull的镜像
docker images
4)使用刚打包的镜像,创建新的容器
-p 端口映射
-v 本地目录映射到容器内
docker run -it -p 80:80 -v /Applications/MAMP/htdocs/:/var/www --privileged=true kfk-lnmp:latest /bin/bash

你可能感兴趣的:(mac docker安装lnmp环境)