多种途径,选择的阿里云服务器。centos环境
- 配置服务器ip安全组,仅暴漏22,80端口
- 购买域名解析到服务器上
- yum -y update //
- dockers手册地址按手册安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun- 换源 方法是编辑/etc/docker/daemon.json(如果不存在则创建):
{ "registry-mirrors":[ "http://docker.mirrors.ustc.edu.cn", "http://registry.docker-cn.com" ] , "insecure-registries":[ "registry.docker-cn.com" ] }
systemctl start docker //启动docker服务 systemctl enable docker //设置开机自动启动 curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose//安装docker-compose sudo chmod +x /usr/local/bin/docker-compose // 赋予执行权限 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose // 创建软链
docker-compose -v //查看安装版本
比较简单
docker search nginx //搜索nginx镜像 docker pull nginx //拉取镜像- 创建nginx配置本地映射目录
cd /home mkdir nginx cd nginx mkdir conf.d log vim defanu.conf写入如下代码
server { listen 80; listen [::]:80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
- docker run -d -p 80:80 -v /home/nginx/conf.d:/etc/nginx/conf.d nginx //docker启动nginx
此时访问域名会显示
到这nginx基本装配完成
/home/nginx/conf.d/ 目录
为配置文件目录