docker 一键部署LNMP服务环境[button color="black" icon="glyphicon glyphicon-star" url="https://hub.docker.com/r/2233466866/lnmp" type=""]Docker项目[/button]Docker# CentOS 6安装 Docker rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum update -y yum -y install docker-io service docker start chkconfig docker on # CentOS 7、Debian、Ubuntu 安装 Docker curl -sSL https://get.docker.com/ | sh systemctl start docker systemctl enable docker下载镜像docker pull 2233466866/lnmp启动容器# 端口映射81 444 3307 9001,容器名称自行指定为lnmp docker run -dit -p 81:80 -p 444:443 -p 3307:3306 -p 9001:9000 -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged=true --name=lnmp 2233466866/lnmp相关命令docker run -dit \ -p 80:80 \ -p 443:443 \ -p 3306:3306 \ -p 9000:9000 \ -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ -v /xxx/www:/www \ -v /xxx/nginx.conf:/usr/local/nginx/conf/nginx.conf \ -v /xxx/mysql:/data/mysql \ -v /xxx/my.cnf:/etc/my.cnf \ --privileged=true \ --name=lnmp \ 2233466866/lnmp连接容器# 容器名称与上一步保持一致 docker exec -it lnmp /bin/bash查看状态ps aux|grep nginx ps aux|grep mysql ps aux|grep php-fpm # 或者(Or) systemctl status nginx systemctl status mysqld systemctl status php7初始密码cat /var/log/mysqld.log|grep 'A temporary password' # 或 password=`cat /var/log/mysqld.log|grep 'A temporary password'`;password=${password:91};echo $password初始化# 请及时修改Mysql的密码(默认并未重置密码和初始化) password=`cat /var/log/mysqld.log|grep 'A temporary password'` password=${password:91} echo -e "${password}\n${password}\n${password}\nn\ny\ny\ny\ny\n" # 以上三条命令的输出为以下命令的输入 mysql_secure_installation配置文件#配置文件路径(Config file path) # Nginx /usr/local/nginx/conf/nginx.conf # MySQL /etc/my.cnf # PHP /usr/local/php7/lib/php.ini /usr/local/php7/etc/php-fpm.conf /usr/local/php7/etc/php-fpm.d/www.confPHP扩展# 默认已安装部分扩展在目录：/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/ # 如果要启用指定扩展，则需要修改php.ini，加上 extension=xxx.so # xxx为PHP扩展的文件名，然后重启php systemctl restart php7