本文首發(fā):http://www.meibug.net/dev-ops/79.html
升級系統(tǒng)
sudo yum -y update
確認(rèn)是否關(guān)閉SELinux
## 查看selinux狀態(tài)
sestatus
>> SELinux status: disabled ## 已關(guān)閉
## 修改selinux
vim /etc/selinux/config
...
SELINUX=disabled
修改軟件源
## 備份系統(tǒng)的軟件源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
## 下載并設(shè)置更新源為aliyun
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
## 下載并設(shè)置EPEL源,此源中包含更多的軟件
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
## 清除yum緩存
yum clean all
## 創(chuàng)建yum緩存
yum makecache
添加用戶并修改密碼
useradd admin
## 提示輸入密碼
passwd admin
為新用戶添加sudo權(quán)限
## 編輯sudoers文件
vim /etc/sudoers
## 先找到這一行
root ALL=(ALL) ALL
## 在下面添加
admin ALL=(ALL) ALL
開啟firewalld并開啟相應(yīng)的端口
## 查看是否開啟
systemctl status firewalld
## 開啟防火墻
systemctl start firewalld
## 查看80端口是否已開啟
firewall-cmd --query-port 80/tpc --permanent
## 添加80端口并一直有效
firewall-cmd --zone=public --add-port=80/tcp --permanent
## 關(guān)閉相應(yīng)的端口
firewall-cmd --zone=public --remove-port=22/tcp --permanent
## 重新加載防火墻
firewall-cmd --reload
修改ssh登陸默認(rèn)端口
## 邊界sshd_config文件
vim /etc/ssh/sshd_config
## 找到以下內(nèi)容
# Port 22
## 修改為想要修改的端口,并去掉前面的‘#’號
Port 2323
## 重啟ssh服務(wù)
systemctl restart sshd