docker 一键部署LNMP服务环境
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.conf
PHP扩展
# 默认已安装部分扩展在目录:/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/
# 如果要启用指定扩展,则需要修改php.ini,加上
extension=xxx.so
# xxx为PHP扩展的文件名,然后重启php
systemctl restart php7
原文链接
https://github.com/2233466866/lnmp
或
https://hub.docker.com/r/2233466866/lnmp