Centos7环境搭建

本文首发:http://www.meibug.net/dev-ops/79.html

升级系统

sudo yum -y update

确认是否关闭SELinux

## 查看selinux状态
sestatus
>> SELinux status: disabled ## 已关闭
## 修改selinux
vim /etc/selinux/config
...
SELINUX=disabled

修改软件源

## 备份系统的软件源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 

## 下载并设置更新源为aliyun
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

## 下载并设置EPEL源,此源中包含更多的软件
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo 

## 清除yum缓存
yum clean all

## 创建yum缓存 
yum makecache

添加用户并修改密码

useradd admin
## 提示输入密码
passwd admin

为新用户添加sudo权限

## 编辑sudoers文件
vim /etc/sudoers

## 先找到这一行
root    ALL=(ALL) ALL 
## 在下面添加
admin   ALL=(ALL) ALL

开启firewalld并开启相应的端口

## 查看是否开启
systemctl status firewalld

## 开启防火墙
systemctl start firewalld

## 查看80端口是否已开启
firewall-cmd --query-port 80/tpc --permanent

## 添加80端口并一直有效
firewall-cmd --zone=public --add-port=80/tcp --permanent 

## 关闭相应的端口
firewall-cmd  --zone=public --remove-port=22/tcp --permanent

## 重新加载防火墙
firewall-cmd --reload

修改ssh登陆默认端口

## 边界sshd_config文件
vim /etc/ssh/sshd_config
## 找到以下内容
# Port 22
## 修改为想要修改的端口,并去掉前面的‘#’号
Port 2323
## 重启ssh服务
systemctl restart sshd 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值