curl -sSL https://get.docker.com/ | sh
安装完成后,通过如下命令启动Docker的守护进程,并让它随系统启动自动加载
sudo service docker start
sudo chkconfig docker on
## 或者
sudo systemctl start docker
sudo systemctl enable docker添加用户(jerry)到Docker组
sudo usermod -aG docker jerry
命令笔记(centos),基于docker镜像2233466866/lnmp
下载镜像
docker pull 2233466866/lnmp
创建基本目录
mkdir -p /app/lnmp/default /docker/lnmp/data/mysql /docker/lnmp/conf/vhost /docker/lnmp/logs /docker/lnmp/temp /docker/lnmp/backup
下载容器配置文件到本地相应目录
docker run -itd -v /sys/fs/cgroup:/sys/fs/cgroup:ro –privileged=true –name=lnmp 2233466866/lnmp
docker exec -it lnmp /bin/bash
docker cp lnmp:/etc/my.cnf /docker/lnmp/conf/my.cnf
docker cp lnmp:/usr/local/nginx/conf/nginx.conf /docker/lnmp/conf/nginx.conf
cp /docker/lnmp/conf/my.cnf /docker/lnmp/backup/my.cnf
cp /docker/lnmp/conf/nginx.conf /docker/lnmp/backup/nginx.conf查看或修改基本配置(代码目录,日志保存目录及vhost目录配置添加)
my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidnginx.conf
停止并删除测试容器
docker stop lnmp
docker rm lnmp重新创建容器
docker run -dit \
-p 80:80 \
-p 443:443 \
-p 3306:3306 \
-p 9000:9000 \
-e TC=”Asia/Shanghai” \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v /app/lnmp:/www \
-v /docker/lnmp/data/mysql:/data/mysql \
-v /docker/lnmp/conf/my.cnf:/etc/my.cnf \
-v /docker/lnmp/conf/nginx.conf:/usr/local/nginx/conf/nginx.conf \
-v /docker/lnmp/conf/vhost:/usr/local/nginx/conf/vhost \
-v /docker/lnmp/logs:/logs \
–privileged=true \
–name=lnmp \
2233466866/lnmpmysql 数据库配置(/etc/my.cnf)
/bin/mysql_secure_installation
cat /var/log/mysqld.log|grep A temporary password
SET PASSWORD = PASSWORD(123456);php.ini 配置(/usr/local/php7/lib/php.ini)
mysqli.default_socket = /var/lib/mysql/mysql.sock
linux 相关设置修改
添加不能登陆的用户www
groupadd www
useradd -M -g www -s /usr/sbin/nologin www修改时区(/etc/profile)
TZ=Asia/Shanghai; export TZ
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime多站点配置
www.test.test.conf
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://www.cnblogs.com/jjxhp/p/12934295.html