前段时间趁着双11打折,又将阿里云主机续费了3年。之前布署的系统是Ubuntu 12.04,从系统发布到现在也有四年半了,其官方支持的生命周期也将止于明年春,且这在几年里出现了很多新的事物,我也需要跟上时代的步伐,于是着手将整个环境更新至最新的Ubuntu 16.04,现将布署过程记录如下
系统布署
环境布署
应用布署
10. 停止服务器实例,选择更换系统盘,选择Ubuntu 16.04 64bit,重启实例
20. 挂载虚拟内存
mkdir /swap && cd /swap && fallocate -l 2g 2GB.swap && mkswap 2GB.swap && swapon 2GB.swap && echo "# # # Swap File # # #" >> /etc/fstab && echo "/swap/2GB.swap none swap sw 0 0" >> /etc/fstab && mount -a
How To Add Swap Space on Ubuntu 16.04
Does it make sense to create swap partitions for new installations nowadways?
30.重新挂载阿里云数据盘
echo ‘/dev/xvdb1 /opt ext4 defaults 0 0‘ >> /etc/fstab && moute -a
40. 新增个人用户
adduser ljz gpasswd -a ljz sudo
后面的操作使用新用户完成
50. 更新软件源
sudo vim /etc/apt/sources.list
可以看到,阿里已经帮我将源指向了阿里镜象自己,这也是最快的选择,所以不需要作任何修改
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse
更新软件源
sudo apt update
升级软件
sudo apt upgrade
What is the difference between apt and apt-get?
60. 解决异常关机后重动时的卡顿
打开引导配置文件
sudo vim /etc/default/grub
增加异常停顿时间参数
GRUB_RECORDFAIL_TIMEOUT=2
保存退出后,更新启动配置
sudo update-grub
How can I force Ubuntu to boot on a stuck boot menu?
Force ubuntu to boot after power failure without user input
70. 安装常用工具
sudo apt install axel zip unzip tree screen
How to list all the files in a tree (a directory and its subdirs)?
80. vim设置
sudo vim /etc/vim/vimrc
在打开的文件最后输入下面的内容
set nu set ai
保存。这样vim显示时就自动显示行号,也能自动缩进了