新服务器初始配置脚本

记录一下新主机的配置脚本,针对ubuntu16.04,安装docker容器运行环境。

创建非root账号

adduser youmeng # 添加新用户
vim /etc/sudoers #编辑权限文件
youmeng ALL=(ALL:ALL) ALL  #在文件 /etc/sudoers 中添加一行

初始化脚本

#!/bin/bash
#新增服务器安装脚本
##################
#配置
echo "开始初始化配置"
apt-get update
apt-get upgrade
#安装软件
apt-get install htop
apt-get install iftop
apt-get install denyhosts
apt-get install git
#安装docker
apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
apt-get update
apt-get install docker-ce
#安装docker compose
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#国内docker 镜像加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://4cea6a0e.m.daocloud.io
# 免sudo 使用docker
groupadd docker
gpasswd -a ${USER} docker
service docker restart
#下载代码
gitUrl="http://xxxx.git"
git config --global credential.helper store
git clone ${gitUrl} #代码仓库的路径
#新建mongodb.log 文件
echo '完成初始化配置'

12 Replies to “新服务器初始配置脚本”

  1. I am the business owner of JustCBD company (justcbdstore.com) and I’m presently planning to broaden my wholesale side of company. It would be great if anybody at targetdomain give me some advice 🙂 I thought that the best way to do this would be to connect to vape companies and cbd stores. I was hoping if someone could recommend a reliable website where I can get CBD Shops BUSINESS DATA I am already reviewing creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Unsure which one would be the most suitable selection and would appreciate any support on this. Or would it be simpler for me to scrape my own leads? Suggestions?

  2. Howdy, I do think your web site may be having web browser compatibility problems. Whenever I take a look at your site in Safari, it looks fine however, when opening in IE, it’s got some overlapping issues. I merely wanted to provide you with a quick heads up! Other than that, great site!

  3. I抦 impressed, I have to say. Actually rarely do I encounter a blog that抯 each educative and entertaining, and let me let you know, you may have hit the nail on the head. Your concept is outstanding; the problem is one thing that not sufficient persons are speaking intelligently about. I am very happy that I stumbled across this in my seek for one thing regarding this.

发表评论

电子邮件地址不会被公开。 必填项已用*标注